Package com.dotmarketing.portlets.structure.model

Examples of com.dotmarketing.portlets.structure.model.ContentletRelationships



    try{

      currentContentlet.setInode(null);
      ContentletRelationships contRel = retrieveRelationshipsData(currentContentlet,user, req );

      // http://jira.dotmarketing.net/browse/DOTCMS-65
      // Coming from other contentlet to relate it automatically
      String relateWith = req.getParameter("relwith");
      String relationType = req.getParameter("reltype");
      String relationHasParent = req.getParameter("relisparent");
      if(relateWith != null){
        try {

          List<ContentletRelationshipRecords> recordsList = contRel.getRelationshipsRecords();
          for(ContentletRelationshipRecords records : recordsList) {
            if(!records.getRelationship().getRelationTypeValue().equals(relationType))
              continue;
            if(RelationshipFactory.isSameStructureRelationship(records.getRelationship()) &&
                ((!records.isHasParent() && relationHasParent.equals("no")) ||
View Full Code Here


      if (key.startsWith("rel_") && key.endsWith("_inodes")) {
        hasParent = key.indexOf("_P_") != -1;
        inodesSt = (String) req.getParameter(key);
        inodes = inodesSt.split(",");
        relationship = (Relationship) InodeFactory.getInode(inodes[0], Relationship.class);
        contentletRelationshipRecords = new ContentletRelationships(null).new ContentletRelationshipRecords(relationship, hasParent);
        records = new ArrayList<Contentlet>();

        for (int i = 1; i < inodes.length; i++) {
          try {
            inode = inodes[i];
            contentlet = contentletAPI.find(inode, user, false);
            if ((contentlet != null) && (InodeUtils.isSet(contentlet.getInode())))
              records.add(contentlet);
          } catch (Exception e) {
            Logger.warn(this, e.toString());
          }
        }

        contentletRelationshipRecords.setRecords(records);
        relationshipsRecords.add(contentletRelationshipRecords);
      }
    }

    ContentletRelationships result = new ContentletRelationships((Contentlet) req.getAttribute(WebKeys.CONTENTLET_EDIT), relationshipsRecords);

    return result;
  }
View Full Code Here

  private ContentletRelationships retrieveRelationshipsData(Contentlet currentcontent, User user, ActionRequest req ){

    Set<String> keys = req.getParameterMap().keySet();

    ContentletRelationships relationshipsData = new ContentletRelationships(currentcontent);
    List<ContentletRelationshipRecords> relationshipsRecords = new ArrayList<ContentletRelationshipRecords> ();
    relationshipsData.setRelationshipsRecords(relationshipsRecords);

    for (String key : keys) {
      if (key.startsWith("rel_") && key.endsWith("_inodes")) {
        boolean hasParent = key.contains("_P_");
        String inodesSt = (String) req.getParameter(key);
View Full Code Here

        cats.add(catAPI.find(tmpString, user, false));
      }
    }

    try{
      ContentletRelationships contRel = retrieveRelationshipsData(currentContentlet,user, contentletFormData );

      // http://jira.dotmarketing.net/browse/DOTCMS-65
      // Coming from other contentlet to relate it automatically
      String relateWith = null;
      if(UtilMethods.isSet(contentletFormData.get("relwith")))
        relateWith = (String) contentletFormData.get("relwith");

      String relationType = null;
      if(UtilMethods.isSet(contentletFormData.get("reltype")))
        relationType = (String) contentletFormData.get("reltype");

      String relationHasParent = null;
      relationHasParent = (String) contentletFormData.get("relisparent");
      if(relateWith != null){
        try {

          List<ContentletRelationshipRecords> recordsList = contRel.getRelationshipsRecords();
          for(ContentletRelationshipRecords records : recordsList) {
            if(!records.getRelationship().getRelationTypeValue().equals(relationType))
              continue;
            if(RelationshipFactory.isSameStructureRelationship(records.getRelationship()) &&
                ((!records.isHasParent() && relationHasParent.equals("no")) ||
View Full Code Here

  }

  private void _loadContentletRelationshipsInRequest(Map<String, Object> contentletFormData, Contentlet contentlet, Structure structure) throws DotDataException {
    ContentletAPI contentletService = APILocator.getContentletAPI();
    contentlet.setStructureInode(structure.getInode());
    ContentletRelationships cRelationships = contentletService.getAllRelationships(contentlet);
    contentletFormData.put(WebKeys.CONTENTLET_RELATIONSHIPS_EDIT, cRelationships);
  }
View Full Code Here

      if (key.startsWith("rel_") && key.endsWith("_inodes")) {
        hasParent = key.indexOf("_P_") != -1;
        inodesSt = (String) contentletFormData.get(key);
        inodes = inodesSt.split(",");
        relationship = (Relationship) InodeFactory.getInode(inodes[0], Relationship.class);
        contentletRelationshipRecords = new ContentletRelationships(null).new ContentletRelationshipRecords(relationship, hasParent);
        records = new ArrayList<Contentlet>();

        for (int i = 1; i < inodes.length; i++) {
          try {
            inode = inodes[i];
            contentlet = contentletAPI.find(inode, user, false);
            if ((contentlet != null) && (InodeUtils.isSet(contentlet.getInode())))
              records.add(contentlet);
          } catch (Exception e) {
            Logger.warn(this, e.toString());
          }
        }

        contentletRelationshipRecords.setRecords(records);
        relationshipsRecords.add(contentletRelationshipRecords);
      }
    }

    ContentletRelationships result = new ContentletRelationships((Contentlet) contentletFormData.get(WebKeys.CONTENTLET_EDIT), relationshipsRecords);

    return result;
  }
View Full Code Here

  private ContentletRelationships retrieveRelationshipsData(Contentlet currentContentlet, User user, Map<String, Object> contentletFormData ){

    Set<String> keys = contentletFormData.keySet();

    ContentletRelationships relationshipsData = new ContentletRelationships(currentContentlet);
    List<ContentletRelationshipRecords> relationshipsRecords = new ArrayList<ContentletRelationshipRecords> ();
    relationshipsData.setRelationshipsRecords(relationshipsRecords);

    for (String key : keys) {
      if (key.startsWith("rel_") && key.endsWith("_inodes")) {
        boolean hasParent = key.contains("_P_");
        String inodesSt = (String) contentletFormData.get(key);
View Full Code Here

          if (!preview)
          {
            cont.setInode(null);
            cont.setLowIndexPriority(true);
            //Load the old relationShips and add the new ones
            ContentletRelationships contentletRelationships = conAPI.getAllRelationships(cont);
            List<ContentletRelationships.ContentletRelationshipRecords> relationshipRecords = contentletRelationships.getRelationshipsRecords();
            for(ContentletRelationships.ContentletRelationshipRecords relationshipRecord : relationshipRecords) {
                            List<Contentlet> csvRelatedContentlet = csvRelationshipRecords.get(relationshipRecord.getRelationship());
                            if(UtilMethods.isSet(csvRelatedContentlet)) {
                                relationshipRecord.getRecords().addAll(csvRelatedContentlet);
                            }
View Full Code Here

             
            }
   
            List<Field> fields = FieldsCache.getFieldsByStructureVariableName(structure.getVelocityVarName());
   
            ContentletRelationships contRel;
            ArrayList<Category> cats;
            User systemUser = null;
            try {
              systemUser = APILocator.getUserAPI().getSystemUser();
            } catch (DotDataException e) {
View Full Code Here

    Structure contentStructure = contentlet.getStructure();
    String relName = Config.getStringProperty("pop."+contentStructure.getVelocityVarName()+".relationship.name");

    if(!UtilMethods.isSet(relName))
      return new ContentletRelationships(contentlet);

    Relationship relationship = new Relationship();
    relationship = RelationshipFactory.getRelationshipByRelationTypeValue(relName);
    if(relationship == null)
      return new ContentletRelationships(contentlet);

    ContentletRelationships relationshipsData = new ContentletRelationships(contentlet);
    List<ContentletRelationshipRecords> relationshipsRecords = new ArrayList<ContentletRelationshipRecords> ();
    relationshipsData.setRelationshipsRecords(relationshipsRecords);

    Structure parentStr = relationship.getParentStructure();
    Structure childStr = relationship.getChildStructure();

    if(contentStructure.equals(childStr)){

      String messageIdFieldVarNm = Config.getStringProperty("pop."+contentStructure.getVelocityVarName()+".relationship.parent.messageId");

      if(!UtilMethods.isSet(messageIdFieldVarNm) && parentStr.equals(childStr)){
        messageIdFieldVarNm = Config.getStringProperty("pop."+contentStructure.getVelocityVarName()+".messageId");
      }

      if(!UtilMethods.isSet(messageIdFieldVarNm))
        return new ContentletRelationships(contentlet);

      List<Contentlet> searchResults = new ArrayList<Contentlet>();
      String luceneQuery = "";     
      String ref = (String)email.get("References");
      String[] references = parseReferences(ref);
View Full Code Here

TOP

Related Classes of com.dotmarketing.portlets.structure.model.ContentletRelationships

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.