use of org.alfresco.service.cmr.dictionary.CustomModelDefinition in project alfresco-remote-api by Alfresco.
the class CustomModelsImpl method getCustomModels.
@Override
public CollectionWithPagingInfo<CustomModel> getCustomModels(Parameters parameters) {
Paging paging = parameters.getPaging();
PagingRequest pagingRequest = Util.getPagingRequest(paging);
PagingResults<CustomModelDefinition> results = customModelService.getCustomModels(pagingRequest);
Integer totalItems = results.getTotalResultCount().getFirst();
List<CustomModelDefinition> page = results.getPage();
List<CustomModel> models = new ArrayList<>(page.size());
for (CustomModelDefinition modelDefinition : page) {
models.add(new CustomModel(modelDefinition));
}
return CollectionWithPagingInfo.asPaged(paging, models, results.hasMoreItems(), (totalItems == null ? null : totalItems.intValue()));
}
use of org.alfresco.service.cmr.dictionary.CustomModelDefinition in project alfresco-remote-api by Alfresco.
the class CustomModelsImpl method createCustomModelImpl.
private CustomModel createCustomModelImpl(CustomModel model, boolean basicModelOnly) {
M2Model m2Model = null;
if (basicModelOnly) {
m2Model = convertToM2Model(model, null, null, null);
} else {
m2Model = convertToM2Model(model, model.getTypes(), model.getAspects(), model.getConstraints());
}
boolean activate = ModelStatus.ACTIVE.equals(model.getStatus());
try {
CustomModelDefinition modelDefinition = customModelService.createCustomModel(m2Model, activate);
return new CustomModel(modelDefinition);
} catch (ModelExistsException me) {
throw new ConstraintViolatedException(me.getMessage());
} catch (CustomModelConstraintException ncx) {
throw new ConstraintViolatedException(ncx.getMessage());
} catch (InvalidCustomModelException iex) {
throw new InvalidArgumentException(iex.getMessage());
} catch (Exception e) {
throw new ApiException("cmm.rest_api.model_invalid", e);
}
}
use of org.alfresco.service.cmr.dictionary.CustomModelDefinition in project alfresco-remote-api by Alfresco.
the class CustomModelsImpl method getCustomModelConstraint.
@Override
public CustomModelConstraint getCustomModelConstraint(String modelName, String constraintName, Parameters parameters) {
if (constraintName == null) {
throw new InvalidArgumentException(CONSTRAINT_NAME_NULL_ERR);
}
final CustomModelDefinition modelDef = getCustomModelImpl(modelName);
QName constraintQname = QName.createQName(modelDef.getName().getNamespaceURI(), constraintName);
ConstraintDefinition constraintDef = customModelService.getCustomConstraint(constraintQname);
if (constraintDef == null) {
throw new EntityNotFoundException(constraintName);
}
return new CustomModelConstraint(constraintDef, dictionaryService);
}
use of org.alfresco.service.cmr.dictionary.CustomModelDefinition in project alfresco-remote-api by Alfresco.
the class CustomModelsImpl method getCustomAspect.
@Override
public CustomAspect getCustomAspect(String modelName, String aspectName, Parameters parameters) {
if (aspectName == null) {
throw new InvalidArgumentException(ASPECT_NAME_NULL_ERR);
}
final CustomModelDefinition modelDef = getCustomModelImpl(modelName);
QName aspectQname = QName.createQName(modelDef.getName().getNamespaceURI(), aspectName);
AspectDefinition customAspectDef = customModelService.getCustomAspect(aspectQname);
if (customAspectDef == null) {
throw new EntityNotFoundException(aspectName);
}
// Check if inherited properties have been requested
boolean includeInheritedProps = hasSelectProperty(parameters, SELECT_ALL_PROPS);
return convertToCustomAspect(customAspectDef, includeInheritedProps);
}
use of org.alfresco.service.cmr.dictionary.CustomModelDefinition in project alfresco-remote-api by Alfresco.
the class CustomModelsImpl method getCustomModelConstraints.
@Override
public CollectionWithPagingInfo<CustomModelConstraint> getCustomModelConstraints(String modelName, Parameters parameters) {
CustomModelDefinition modelDef = getCustomModelImpl(modelName);
Collection<ConstraintDefinition> constraintDefinitions = modelDef.getModelDefinedConstraints();
// TODO Should we support paging?
Paging paging = Paging.DEFAULT;
List<CustomModelConstraint> customModelConstraints = convertToCustomModelConstraints(constraintDefinitions);
return CollectionWithPagingInfo.asPaged(paging, customModelConstraints, false, constraintDefinitions.size());
}
Aggregations