All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.bonitasoft.engine.theme.persistence.SelectDescriptorBuilder Maven / Gradle / Ivy

There is a newer version: 10.2.0
Show newest version
/**
 * Copyright (C) 2019 Bonitasoft S.A.
 * Bonitasoft, 32 rue Gustave Eiffel - 38000 Grenoble
 * This library is free software; you can redistribute it and/or modify it under the terms
 * of the GNU Lesser General Public License as published by the Free Software Foundation
 * version 2.1 of the License.
 * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU Lesser General Public License for more details.
 * You should have received a copy of the GNU Lesser General Public License along with this
 * program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
 * Floor, Boston, MA 02110-1301, USA.
 **/
package org.bonitasoft.engine.theme.persistence;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

import org.bonitasoft.engine.persistence.OrderByType;
import org.bonitasoft.engine.persistence.PersistentObject;
import org.bonitasoft.engine.persistence.QueryOptions;
import org.bonitasoft.engine.persistence.SelectByIdDescriptor;
import org.bonitasoft.engine.persistence.SelectListDescriptor;
import org.bonitasoft.engine.persistence.SelectOneDescriptor;
import org.bonitasoft.engine.theme.model.STheme;
import org.bonitasoft.engine.theme.model.SThemeType;

/**
 * @author Celine Souchet
 */
public class SelectDescriptorBuilder {

    private SelectDescriptorBuilder() {
        // For Sonar
    }

    public static  SelectByIdDescriptor getElementById(final Class clazz,
            final String elementName, final long id) {
        return new SelectByIdDescriptor(clazz, id);
    }

    public static SelectOneDescriptor getNumberOfElement(final String elementName,
            final Class clazz) {
        final Map parameters = Collections.emptyMap();
        return new SelectOneDescriptor("getNumberOf" + elementName, parameters, clazz, Long.class);
    }

    public static  SelectListDescriptor getElements(final Class clazz,
            final String elementName, final int fromIndex,
            final int numberOfElements) {
        final QueryOptions queryOptions = new QueryOptions(fromIndex, numberOfElements);
        return getElements(clazz, elementName, queryOptions);
    }

    public static  SelectListDescriptor getElements(final Class clazz,
            final String elementName, final String field,
            final OrderByType order, final int fromIndex, final int numberOfElements) {
        final QueryOptions queryOptions = new QueryOptions(fromIndex, numberOfElements, clazz, field, order);
        return getElements(clazz, elementName, queryOptions);
    }

    public static  SelectListDescriptor getElements(final Class clazz,
            final String elementName,
            final QueryOptions queryOptions) {
        final Map parameters = Collections.emptyMap();
        return new SelectListDescriptor("get" + elementName + "s", parameters, clazz, queryOptions);
    }

    public static SelectOneDescriptor getTheme(SThemeType type, boolean isDefault) {
        final Map inputParameters = new HashMap(1);
        inputParameters.put("type", type);
        inputParameters.put("isDefault", isDefault);
        return new SelectOneDescriptor("getTheme", inputParameters, STheme.class);
    }

    public static SelectOneDescriptor getLastModifiedTheme(SThemeType type) {
        final Map inputParameters = new HashMap(1);
        inputParameters.put("type", type);
        return new SelectOneDescriptor("getLastModifiedTheme", inputParameters, STheme.class);
    }

    public static SelectOneDescriptor getLastUpdateDate(SThemeType type) {
        final Map inputParameters = new HashMap(1);
        inputParameters.put("type", type);
        return new SelectOneDescriptor("getLastUpdateDate", inputParameters, STheme.class);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy