Search in sources :

Example 1 with SmallContentType

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));
    }
}
Also used : ContentModel(com.agiletec.plugins.jacms.aps.system.services.contentmodel.ContentModel) SmallContentType(com.agiletec.plugins.jacms.aps.system.services.content.model.SmallContentType)

Example 2 with SmallContentType

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());
}
Also used : SmallContentType(com.agiletec.plugins.jacms.aps.system.services.content.model.SmallContentType)

Example 3 with SmallContentType

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;
}
Also used : HashMap(java.util.HashMap) SmallEntityType(com.agiletec.aps.system.common.entity.model.SmallEntityType) SmallContentType(com.agiletec.plugins.jacms.aps.system.services.content.model.SmallContentType)

Example 4 with SmallContentType

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;
}
Also used : Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) SmallContentType(com.agiletec.plugins.jacms.aps.system.services.content.model.SmallContentType)

Aggregations

SmallContentType (com.agiletec.plugins.jacms.aps.system.services.content.model.SmallContentType)4 SmallEntityType (com.agiletec.aps.system.common.entity.model.SmallEntityType)1 Content (com.agiletec.plugins.jacms.aps.system.services.content.model.Content)1 ContentModel (com.agiletec.plugins.jacms.aps.system.services.contentmodel.ContentModel)1 HashMap (java.util.HashMap)1