Search in sources :

Example 1 with AbstractJAXBAttribute

use of com.agiletec.aps.system.common.entity.model.attribute.AbstractJAXBAttribute in project entando-core by entando.

the class JAXBEntity method buildEntity.

public IApsEntity buildEntity(IApsEntity prototype, ICategoryManager categoryManager) {
    try {
        prototype.setDescription(this.getDescription());
        prototype.setId(this.getId());
        prototype.setMainGroup(this.getMainGroup());
        prototype.setTypeCode(this.getTypeCode());
        prototype.setTypeDescription(this.getTypeDescription());
        if (null != this.getGroups() && !this.getGroups().isEmpty()) {
            Iterator<String> iter = this.getGroups().iterator();
            while (iter.hasNext()) {
                prototype.addGroup(iter.next());
            }
        }
        if (null != this.getCategories() && !this.getCategories().isEmpty()) {
            Iterator<String> iter = this.getCategories().iterator();
            while (iter.hasNext()) {
                String categoryCode = iter.next();
                Category category = categoryManager.getCategory(categoryCode);
                if (null != category) {
                    prototype.addCategory(category);
                }
            }
        }
        if (null == this.getAttributes()) {
            return prototype;
        }
        for (int i = 0; i < this.getAttributes().size(); i++) {
            AbstractJAXBAttribute jaxrAttribute = this.getAttributes().get(i);
            AttributeInterface attribute = (AttributeInterface) prototype.getAttribute(jaxrAttribute.getName());
            if (null != attribute && attribute.getType().equals(jaxrAttribute.getType())) {
                attribute.valueFrom(jaxrAttribute);
            }
        }
    } catch (Throwable t) {
        _logger.error("Error creating Entity", t);
        throw new RuntimeException("Error creating Entity", t);
    }
    return prototype;
}
Also used : Category(com.agiletec.aps.system.services.category.Category) AbstractJAXBAttribute(com.agiletec.aps.system.common.entity.model.attribute.AbstractJAXBAttribute) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)

Aggregations

AbstractJAXBAttribute (com.agiletec.aps.system.common.entity.model.attribute.AbstractJAXBAttribute)1 AttributeInterface (com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)1 Category (com.agiletec.aps.system.services.category.Category)1