Search in sources :

Example 1 with DataDefinition

use of com.qcadoo.model.api.DataDefinition in project qcadoo by qcadoo.

the class CustomTranslationManagementServiceImpl method removeCustomTranslations.

@Override
@Transactional
public void removeCustomTranslations(final String pluginIdentifier) {
    DataDefinition customTranslationDD = getCustomTranslationDD();
    Session currentSession = getCurrentSession(customTranslationDD);
    currentSession.createQuery("UPDATE com.qcadoo.model.beans.qcadooCustomTranslation.QcadooCustomTranslationCustomTranslation " + "SET active = false WHERE pluginIdentifier = :pluginIdentifier AND active = true").setString("pluginIdentifier", pluginIdentifier).executeUpdate();
}
Also used : DataDefinition(com.qcadoo.model.api.DataDefinition) Session(org.hibernate.classic.Session) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with DataDefinition

use of com.qcadoo.model.api.DataDefinition in project qcadoo by qcadoo.

the class UserGroupModule method multiTenantEnable.

@Override
public void multiTenantEnable() {
    if (dataDefinitionService.get("qcadooSecurity", "group").find().add(SearchRestrictions.eq("identifier", identifier)).list().getTotalNumberOfEntities() > 0) {
        return;
    }
    Entity entity = dataDefinitionService.get("qcadooSecurity", "group").create();
    entity.setField("name", name);
    entity.setField("identifier", identifier);
    DataDefinition roleDD = dataDefinitionService.get("qcadooSecurity", "role");
    entity.setField("roles", roleDD.find().add(SearchRestrictions.in("identifier", (Object[]) roles.split(","))).list().getEntities());
    dataDefinitionService.get("qcadooSecurity", "group").save(entity);
}
Also used : Entity(com.qcadoo.model.api.Entity) DataDefinition(com.qcadoo.model.api.DataDefinition)

Example 3 with DataDefinition

use of com.qcadoo.model.api.DataDefinition in project qcadoo by qcadoo.

the class NumberGeneratorModelHelper method getNumbersProjection.

/**
 * Returns a list of projection entities containing NUM_PROJECTION_ALIAS field with numberFieldName values with trimmed out
 * leading zeros. List is sorted descendant by numberFieldName.
 *
 * @param pluginIdentifier
 *            identifier of the plugin
 * @param modelName
 *            name of the model
 * @param numberFieldName
 *            name of the field for which number will be generated
 * @param prefix
 *            number prefix
 * @param suffix
 *            number suffix
 * @return a list of projection entities containing NUM_PROJECTION_ALIAS field with numberFieldName values with trimmed out
 *         leading zeros. List is sorted descendant by numberFieldName.
 */
public Collection<Entity> getNumbersProjection(final String pluginIdentifier, final String modelName, final String numberFieldName, final String prefix, final String suffix) {
    DataDefinition dd = dataDefinitionService.get(pluginIdentifier, modelName);
    String hqlQuery = buildQuery(pluginIdentifier, modelName, numberFieldName, prefix, suffix);
    return dd.find(hqlQuery).list().getEntities();
}
Also used : DataDefinition(com.qcadoo.model.api.DataDefinition)

Example 4 with DataDefinition

use of com.qcadoo.model.api.DataDefinition in project qcadoo by qcadoo.

the class FieldComponentPattern method getJspOptions.

@Override
protected Map<String, Object> getJspOptions(final Locale locale) {
    Map<String, Object> options = new HashMap<String, Object>();
    Map<String, Object> translations = new HashMap<String, Object>();
    if (getFieldDefinition() == null) {
        translations.put(LABEL, getTranslationService().translate(getTranslationPath() + LABEL_SUFFIX, locale));
    } else {
        String code1 = getFieldDefinition().getDataDefinition().getPluginIdentifier() + "." + getFieldDefinition().getDataDefinition().getName() + "." + getFieldDefinition().getName() + LABEL_SUFFIX;
        if (BelongsToType.class.isAssignableFrom(getFieldDefinition().getType().getClass())) {
            DataDefinition fieldDataDefinition = ((BelongsToType) getFieldDefinition().getType()).getDataDefinition();
            String code2 = fieldDataDefinition.getPluginIdentifier() + "." + fieldDataDefinition.getName() + "." + getFieldDefinition().getName() + LABEL_SUFFIX;
            translations.put(LABEL, getTranslationService().translate(getTranslationPath() + LABEL_SUFFIX, code1, code2, locale));
        } else {
            translations.put(LABEL, getTranslationService().translate(getTranslationPath() + LABEL_SUFFIX, code1, locale));
        }
    }
    if (isHasDescription()) {
        translations.put("description", getTranslationService().translate(getTranslationPath() + ".description", locale));
        translations.put("descriptionHeader", getTranslationService().translate(getTranslationPath() + ".descriptionHeader", "qcadooView.form.descriptionHeader", locale));
    }
    options.put("translations", translations);
    options.put("labelWidth", labelWidth);
    return options;
}
Also used : BelongsToType(com.qcadoo.model.api.types.BelongsToType) HashMap(java.util.HashMap) DataDefinition(com.qcadoo.model.api.DataDefinition)

Example 5 with DataDefinition

use of com.qcadoo.model.api.DataDefinition in project qcadoo by qcadoo.

the class EntityTestUtils method mockDataDefinition.

public static DataDefinition mockDataDefinition() {
    DataDefinition dd = mock(DataDefinition.class);
    BDDMockito.given(dd.save(any(Entity.class))).willAnswer(invocation -> (Entity) invocation.getArguments()[0]);
    BDDMockito.given(dd.delete(Matchers.<Long>anyVararg())).willAnswer(invocation -> EntityOpResult.successfull());
    return dd;
}
Also used : Entity(com.qcadoo.model.api.Entity) DataDefinition(com.qcadoo.model.api.DataDefinition)

Aggregations

DataDefinition (com.qcadoo.model.api.DataDefinition)415 Entity (com.qcadoo.model.api.Entity)285 Test (org.junit.Test)165 BigDecimal (java.math.BigDecimal)53 FieldDefinition (com.qcadoo.model.api.FieldDefinition)48 List (java.util.List)32 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)32 Service (org.springframework.stereotype.Service)31 Autowired (org.springframework.beans.factory.annotation.Autowired)27 Date (java.util.Date)26 Map (java.util.Map)26 Collectors (java.util.stream.Collectors)26 FormComponent (com.qcadoo.view.api.components.FormComponent)25 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)23 DataDefinitionService (com.qcadoo.model.api.DataDefinitionService)22 IOException (java.io.IOException)21 Objects (java.util.Objects)21 GridComponent (com.qcadoo.view.api.components.GridComponent)20 InternalViewDefinition (com.qcadoo.view.internal.api.InternalViewDefinition)20 Lists (com.google.common.collect.Lists)16