use of com.qcadoo.model.api.Entity in project qcadoo by qcadoo.
the class TranslationUtilsService method getItemDescriptionTranslation.
/**
* Returns menu item description translation
*
* @param item
* category entity
* @param locale
* localization
* @return item description translation or empty String if translation does not exists
*
* @since 1.1.3
*/
public String getItemDescriptionTranslation(final Entity item, final Locale locale) {
Entity category = item.getBelongsToField(L_CATEGORY);
String translationKey = item.getStringField(L_PLUGIN_IDENTIFIER) + L_MENU + category.getStringField(L_NAME) + '.' + item.getStringField(L_NAME) + ".description";
return translateAndIgnoreMissingMessages(translationKey, locale);
}
use of com.qcadoo.model.api.Entity in project qcadoo by qcadoo.
the class AlertsDbHelper method registerAlert.
void registerAlert(final AlertDto alert) {
Entity alertEntity = getAlertDD().create();
alertEntity.setField(AlertFields.TYPE, alert.getType());
alertEntity.setField(AlertFields.MESSAGE, alert.getMessage());
alertEntity.setField(AlertFields.EXPIRATION_DATE, alert.getExpirationDate());
alertEntity.setField(AlertFields.SOUND, alert.isSound());
alertEntity.getDataDefinition().save(alertEntity);
}
use of com.qcadoo.model.api.Entity in project qcadoo by qcadoo.
the class AlertsDbHelper method createViewedAlert.
private void createViewedAlert(final Long id, final Entity user) {
Entity viewedAlert = getViewdAlertDD().create();
Entity alert = dataDefinitionService.get(QcadooViewConstants.PLUGIN_IDENTIFIER, QcadooViewConstants.MODEL_ALERT).get(id);
viewedAlert.setField(ViewedAlertFields.USER, user);
viewedAlert.setField(ViewedAlertFields.ALERT, alert);
viewedAlert.getDataDefinition().save(viewedAlert);
}
use of com.qcadoo.model.api.Entity 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;
}
use of com.qcadoo.model.api.Entity in project qcadoo by qcadoo.
the class EntityTestUtils method stubDateField.
public static void stubDateField(final Entity entity, final String fieldName, final Date fieldValue) {
Answer<Date> answer = invocation -> {
if (fieldValue == null) {
return null;
}
return new Date(fieldValue.getTime());
};
BDDMockito.given(entity.getDateField(fieldName)).willAnswer(answer);
stubField(entity, fieldName, answer);
}
Aggregations