use of com.agiletec.plugins.jacms.aps.system.services.content.model.SmallContentType in project entando-core by entando.
the class ContentModelAction method checkModelId.
private void checkModelId() {
if (null == this.getModelId())
return;
ContentModel dummyModel = this.getContentModelManager().getContentModel(this.getModelId());
if (dummyModel != null) {
this.addFieldError("modelId", this.getText("error.contentModel.modelId.alreadyPresent"));
}
SmallContentType utilizer = this.getContentModelManager().getDefaultUtilizer(this.getModelId());
if (null != utilizer && !utilizer.getCode().equals(this.getContentType())) {
String[] args = { this.getModelId().toString(), utilizer.getDescr() };
this.addFieldError("modelId", this.getText("error.contentModel.modelId.wrongUtilizer", args));
}
}
use of com.agiletec.plugins.jacms.aps.system.services.content.model.SmallContentType in project entando-core by entando.
the class ContentModelManagerIntegrationTest method testGetTypeUtilizer.
public void testGetTypeUtilizer() throws Throwable {
SmallContentType utilizer = this._contentModelManager.getDefaultUtilizer(1);
assertNotNull(utilizer);
assertEquals("ART", utilizer.getCode());
utilizer = this._contentModelManager.getDefaultUtilizer(11);
assertNotNull(utilizer);
assertEquals("ART", utilizer.getCode());
utilizer = this._contentModelManager.getDefaultUtilizer(126);
assertNotNull(utilizer);
assertEquals("RAH", utilizer.getCode());
}
use of com.agiletec.plugins.jacms.aps.system.services.content.model.SmallContentType in project entando-core by entando.
the class ContentManager method getSmallContentTypesMap.
/**
* Return the map of the prototypes of the contents types. Return a map,
* index by the code of the type, of the prototypes of the available content
* types.
*
* @return The map of the prototypes of the content types in a
* 'SmallContentType' objects.
*/
@Override
public Map<String, SmallContentType> getSmallContentTypesMap() {
Map<String, SmallContentType> smallContentTypes = new HashMap<>();
List<SmallEntityType> entityTypes = super.getSmallEntityTypes();
for (SmallEntityType entityType : entityTypes) {
SmallContentType sct = new SmallContentType();
sct.setCode(entityType.getCode());
sct.setDescription(entityType.getDescription());
smallContentTypes.put(entityType.getCode(), sct);
}
return smallContentTypes;
}
use of com.agiletec.plugins.jacms.aps.system.services.content.model.SmallContentType in project entando-core by entando.
the class ContentModelManager method getDefaultUtilizer.
@Override
public SmallContentType getDefaultUtilizer(long modelId) {
String modelIdString = String.valueOf(modelId);
List<SmallContentType> smallContentTypes = this.getContentManager().getSmallContentTypes();
for (int i = 0; i < smallContentTypes.size(); i++) {
SmallContentType smallContentType = (SmallContentType) smallContentTypes.get(i);
Content prototype = this.getContentManager().createContentType(smallContentType.getCode());
if ((null != prototype.getListModel() && prototype.getListModel().equals(modelIdString)) || (null != prototype.getDefaultModel() && prototype.getDefaultModel().equals(modelIdString))) {
return smallContentType;
}
}
return null;
}
Aggregations