use of com.qcadoo.model.internal.DataDefinitionImpl in project qcadoo by qcadoo.
the class ModelXmlToDefinitionConverterImpl method getModelDefinition.
private DataDefinitionImpl getModelDefinition(final XMLStreamReader reader, final String pluginIdentifier) {
String modelName = getStringAttribute(reader, "name");
LOG.info("Reading model " + modelName + " for plugin " + pluginIdentifier);
DataDefinitionImpl dataDefinition = new DataDefinitionImpl(pluginIdentifier, modelName, dataAccessService);
dataDefinition.setDeletable(getBooleanAttribute(reader, "deletable", true));
dataDefinition.setInsertable(getBooleanAttribute(reader, "insertable", true));
dataDefinition.setUpdatable(getBooleanAttribute(reader, "updatable", true));
dataDefinition.setActivable(getBooleanAttribute(reader, "activable", false));
dataDefinition.setAuditable(getBooleanAttribute(reader, "auditable", false));
if (dataDefinition.isAuditable()) {
addAuditFields(dataDefinition);
}
dataDefinition.setVersionable(getBooleanAttribute(reader, VersionableConstants.VERSIONABLE_ATTRIBUTE_NAME, false));
if (dataDefinition.isVersionable()) {
addVersionFields(dataDefinition);
}
dataDefinition.setFullyQualifiedClassName(ClassNameUtils.getFullyQualifiedClassName(pluginIdentifier, modelName));
return dataDefinition;
}
use of com.qcadoo.model.internal.DataDefinitionImpl in project qcadoo by qcadoo.
the class ModelXmlToDefinitionConverterImpl method getDataDefinition.
private DataDefinition getDataDefinition(final XMLStreamReader reader, final String pluginIdentifier) throws XMLStreamException, HookInitializationException, ModelXmlParsingException {
DataDefinitionImpl dataDefinition = getModelDefinition(reader, pluginIdentifier);
LOG.info("Creating dataDefinition " + dataDefinition);
parseElementChildren(reader, TAG_MODEL, childTag -> {
if (TAG_FIELDS.equals(getTagStarted(reader))) {
parseFields(reader, dataDefinition);
}
if (TAG_HOOKS.equals(getTagStarted(reader))) {
parseHooks(reader, dataDefinition);
}
String tag = getTagStarted(reader);
if (tag != null) {
addOtherElement(reader, dataDefinition, tag);
}
});
dataDefinitionService.save(dataDefinition);
return dataDefinition;
}
use of com.qcadoo.model.internal.DataDefinitionImpl in project qcadoo by qcadoo.
the class ModelXmlToDefinitionConverterTest method shouldSetHooks.
@Test
public void shouldSetHooks() {
DataDefinitionImpl dataDefImpl = (DataDefinitionImpl) dataDefinition;
testListHookDefinition(dataDefImpl.getCreateHooks(), CustomHook.class, "createHook");
testListHookDefinition(dataDefImpl.getUpdateHooks(), CustomHook.class, "updateHook");
testListHookDefinition(dataDefImpl.getSaveHooks(), CustomHook.class, "hook");
testListHookDefinition(dataDefImpl.getCopyHooks(), CustomHook.class, "copyHook");
testListHookDefinition(dataDefImpl.getDeleteHooks(), CustomHook.class, "deleteHook");
}
use of com.qcadoo.model.internal.DataDefinitionImpl in project qcadoo by qcadoo.
the class ModelXmlToDefinitionConverterTest method shouldSetEntityValidators.
@Test
public void shouldSetEntityValidators() {
assertEquals(1, ((DataDefinitionImpl) dataDefinition).getValidators().size());
EntityHookDefinition validator = ((DataDefinitionImpl) dataDefinition).getValidators().get(0);
assertThat(validator, instanceOf(CustomEntityValidator.class));
testHookDefinition(validator, "entityHook", CustomHook.class, "validate");
}
Aggregations