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();
}
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);
}
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();
}
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;
}
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;
}
Aggregations