@Override public AspectDefinition getCustomAspect(QName name) { ParameterCheck.mandatory("name", name); CompiledModel compiledModel = getModelByUri(name.getNamespaceURI()); if (compiledModel != null) { return compiledModel.getAspect(name); } return null; }
@Override public PagingResults<AspectDefinition> getAllCustomAspects(PagingRequest pagingRequest) { ParameterCheck.mandatory("pagingRequest", pagingRequest); List<AspectDefinition> result = new ArrayList<>(); List<CompiledModel> list = getAllCustomM2Models(false); for (CompiledModel model : list) { result.addAll(model.getAspects()); } return wrapResult(pagingRequest, result); }
@Override public ConstraintDefinition getCustomConstraint(QName name) { ParameterCheck.mandatory("name", name); CompiledModel compiledModel = getModelByUri(name.getNamespaceURI()); if (compiledModel != null) { return compiledModel.getConstraint(name); } return null; }
if (!customModelDefinition.getName().equals(cm.getModelDefinition().getName())) validateTypeAspectDependency(modelTypes, cm.getTypes()); validateTypeAspectDependency(modelAspects, cm.getAspects());
private CompiledModel getModelByUri(String uri) { for (CompiledModel model : getAllCustomM2Models(false)) { if (uri.equals(getModelNamespaceUriPrefix(model.getM2Model()).getFirst())) { return model; } } return null; }
if (compiledModel.getModelDefinition().getName().equals(model)) propDefs = compiledModel.getProperties();
public void validateModel(CompiledModel compiledModel) ModelDefinition modelDef = compiledModel.getModelDefinition(); QName modelName = modelDef.getName(); M2Model model = compiledModel.getM2Model();
@Override public ModelDefinition getCustomModelByUri(String namespaceUri) { ParameterCheck.mandatoryString("namespaceUri", namespaceUri); CompiledModel compiledModel = getModelByUri(namespaceUri); if (compiledModel != null) { return compiledModel.getModelDefinition(); } return null; }
@Override public TypeDefinition getCustomType(QName name) { ParameterCheck.mandatory("name", name); CompiledModel compiledModel = getModelByUri(name.getNamespaceURI()); if (compiledModel != null) { return compiledModel.getType(name); } return null; }
@Override public PagingResults<TypeDefinition> getAllCustomTypes(PagingRequest pagingRequest) { ParameterCheck.mandatory("pagingRequest", pagingRequest); List<TypeDefinition> result = new ArrayList<>(); List<CompiledModel> list = getAllCustomM2Models(false); for (CompiledModel model : list) { result.addAll(model.getTypes()); } return wrapResult(pagingRequest, result); }
/** * Validates the properties' non-null default values against the defined property constraints. * * @param compiledModel the compiled model * @throws CustomModelException.CustomModelConstraintException if there is constraint evaluation * exception */ private void validatePropsDefaultValues(CompiledModel compiledModel) { for (PropertyDefinition propertyDef : compiledModel.getProperties()) { if (propertyDef.getDefaultValue() != null && propertyDef.getConstraints().size() > 0) { for (ConstraintDefinition constraintDef : propertyDef.getConstraints()) { Constraint constraint = constraintDef.getConstraint(); try { constraint.evaluate(propertyDef.getDefaultValue()); } catch (AlfrescoRuntimeException ex) { String message = getRootCauseMsg(ex, false, "cmm.service.constraint.default_prop_value_err"); throw new CustomModelException.CustomModelConstraintException(message); } } } } }
if (!customModelDefinition.getName().equals(cm.getModelDefinition().getName())) validateTypeAspectDependency(modelTypes, cm.getTypes()); validateTypeAspectDependency(modelAspects, cm.getAspects());
private CompiledModel getModelByUri(String uri) { for (CompiledModel model : getAllCustomM2Models(false)) { if (uri.equals(getModelNamespaceUriPrefix(model.getM2Model()).getFirst())) { return model; } } return null; }
if (compiledModel.getModelDefinition().getName().equals(model)) propDefs = compiledModel.getProperties();
public void validateModel(CompiledModel compiledModel) ModelDefinition modelDef = compiledModel.getModelDefinition(); QName modelName = modelDef.getName(); M2Model model = compiledModel.getM2Model();
@Override public ModelDefinition getCustomModelByUri(String namespaceUri) { ParameterCheck.mandatoryString("namespaceUri", namespaceUri); CompiledModel compiledModel = getModelByUri(namespaceUri); if (compiledModel != null) { return compiledModel.getModelDefinition(); } return null; }
@Override public TypeDefinition getCustomType(QName name) { ParameterCheck.mandatory("name", name); CompiledModel compiledModel = getModelByUri(name.getNamespaceURI()); if (compiledModel != null) { return compiledModel.getType(name); } return null; }
@Override public PagingResults<TypeDefinition> getAllCustomTypes(PagingRequest pagingRequest) { ParameterCheck.mandatory("pagingRequest", pagingRequest); List<TypeDefinition> result = new ArrayList<>(); List<CompiledModel> list = getAllCustomM2Models(false); for (CompiledModel model : list) { result.addAll(model.getTypes()); } return wrapResult(pagingRequest, result); }
/** * Validates the properties' non-null default values against the defined property constraints. * * @param compiledModel the compiled model * @throws CustomModelException.CustomModelConstraintException if there is constraint evaluation * exception */ private void validatePropsDefaultValues(CompiledModel compiledModel) { for (PropertyDefinition propertyDef : compiledModel.getProperties()) { if (propertyDef.getDefaultValue() != null && propertyDef.getConstraints().size() > 0) { for (ConstraintDefinition constraintDef : propertyDef.getConstraints()) { Constraint constraint = constraintDef.getConstraint(); try { constraint.evaluate(propertyDef.getDefaultValue()); } catch (AlfrescoRuntimeException ex) { String message = getRootCauseMsg(ex, false, "cmm.service.constraint.default_prop_value_err"); throw new CustomModelException.CustomModelConstraintException(message); } } } } }
protected List<CustomModelDefinition> getAllCustomModels() { List<CustomModelDefinition> result = new ArrayList<>(); Collection<QName> models = dictionaryDAO.getModels(true); List<String> dictionaryModels = new ArrayList<>(); for (QName model : models) { dictionaryModels.add(model.toPrefixString()); } List<CompiledModel> compiledModels = getAllCustomM2Models(false); if (compiledModels.size() > 0) { for (CompiledModel model : compiledModels) { // check against models loaded in dictionary boolean isActive = false; if (dictionaryModels.contains(model.getM2Model().getName())) { isActive = true; } result.add(new CustomModelDefinitionImpl(model, isActive, dictionaryService)); } } return result; }