Search in sources :

Example 6 with CmsAttributeReference

use of com.agiletec.plugins.jacms.aps.system.services.content.model.CmsAttributeReference in project entando-core by entando.

the class LinkAttribute method getReferences.

@Override
public List<CmsAttributeReference> getReferences(List<Lang> systemLangs) {
    List<CmsAttributeReference> refs = new ArrayList<>();
    SymbolicLink symbLink = this.getSymbolicLink();
    if (null != symbLink && (symbLink.getDestType() != SymbolicLink.URL_TYPE)) {
        CmsAttributeReference ref = new CmsAttributeReference(symbLink.getPageDest(), symbLink.getContentDest(), null);
        refs.add(ref);
    }
    return refs;
}
Also used : ArrayList(java.util.ArrayList) CmsAttributeReference(com.agiletec.plugins.jacms.aps.system.services.content.model.CmsAttributeReference) SymbolicLink(com.agiletec.plugins.jacms.aps.system.services.content.model.SymbolicLink)

Example 7 with CmsAttributeReference

use of com.agiletec.plugins.jacms.aps.system.services.content.model.CmsAttributeReference in project entando-core by entando.

the class ContentDAO method addContentRelationsRecord.

/**
 * Add a record in the table 'contentrelations' for every resource, page,
 * other content, role and category associated to the given content).
 *
 * @param content
 * The current content.
 * @param conn
 * The connection to the database.
 * @throws ApsSystemException
 * when connection error are detected.
 */
protected void addContentRelationsRecord(Content content, Connection conn) throws ApsSystemException {
    PreparedStatement stat = null;
    try {
        stat = conn.prepareStatement(ADD_CONTENT_REL_RECORD);
        this.addCategoryRelationsRecord(content, true, stat);
        this.addGroupRelationsRecord(content, stat);
        EntityAttributeIterator attributeIter = new EntityAttributeIterator(content);
        while (attributeIter.hasNext()) {
            AttributeInterface currAttribute = (AttributeInterface) attributeIter.next();
            if (currAttribute instanceof IReferenceableAttribute) {
                IReferenceableAttribute cmsAttribute = (IReferenceableAttribute) currAttribute;
                List<CmsAttributeReference> refs = cmsAttribute.getReferences(this.getLangManager().getLangs());
                for (int i = 0; i < refs.size(); i++) {
                    CmsAttributeReference ref = refs.get(i);
                    stat.setString(1, content.getId());
                    stat.setString(2, ref.getRefPage());
                    stat.setString(3, ref.getRefContent());
                    stat.setString(4, ref.getRefResource());
                    stat.setString(5, null);
                    stat.setString(6, null);
                    stat.addBatch();
                    stat.clearParameters();
                }
            }
        }
        stat.executeBatch();
    } catch (BatchUpdateException e) {
        _logger.error("Error saving record into contentrelations {}", content.getId(), e.getNextException());
        throw new RuntimeException("Error saving record into contentrelations " + content.getId(), e.getNextException());
    } catch (Throwable t) {
        _logger.error("Error saving record into contentrelations {}", content.getId(), t);
        throw new RuntimeException("Error saving record into contentrelations " + content.getId(), t);
    } finally {
        closeDaoResources(null, stat);
    }
}
Also used : IReferenceableAttribute(com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.IReferenceableAttribute) PreparedStatement(java.sql.PreparedStatement) CmsAttributeReference(com.agiletec.plugins.jacms.aps.system.services.content.model.CmsAttributeReference) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface) EntityAttributeIterator(com.agiletec.aps.system.common.util.EntityAttributeIterator) BatchUpdateException(java.sql.BatchUpdateException)

Aggregations

CmsAttributeReference (com.agiletec.plugins.jacms.aps.system.services.content.model.CmsAttributeReference)7 ArrayList (java.util.ArrayList)5 AttributeInterface (com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)4 IReferenceableAttribute (com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.IReferenceableAttribute)4 EntityAttributeIterator (com.agiletec.aps.system.common.util.EntityAttributeIterator)3 Lang (com.agiletec.aps.system.services.lang.Lang)3 SymbolicLink (com.agiletec.plugins.jacms.aps.system.services.content.model.SymbolicLink)3 Content (com.agiletec.plugins.jacms.aps.system.services.content.model.Content)2 IPage (com.agiletec.aps.system.services.page.IPage)1 IPageManager (com.agiletec.aps.system.services.page.IPageManager)1 SymbolicLinkValidator (com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.util.SymbolicLinkValidator)1 ResourceInterface (com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceInterface)1 BatchUpdateException (java.sql.BatchUpdateException)1 PreparedStatement (java.sql.PreparedStatement)1