Package com.dotmarketing.portlets.structure.model

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


        StructureServices.removeStructureFile(slideSt);
        StructureFactory.saveStructure(slideSt);
      }

     
      Relationship relationship = RelationshipFactory.getRelationshipByRelationTypeValue("Slide_Show-Slide_Image");
      if (!InodeUtils.isSet(relationship.getInode())) {
        //create the relationship
        relationship = new Relationship (slideShowSt, slideSt, "Slide Show", "Slide Image", com.dotmarketing.util.WebKeys.Relationship.RELATIONSHIP_CARDINALITY.ONE_TO_MANY.ordinal(), false, false);
        RelationshipFactory.saveRelationship(relationship);
      }
     
      ContentletAPI conAPI = APILocator.getContentletAPI();
      StringBuffer lqBuffy = new StringBuffer();
View Full Code Here


     
      deleteRelatedContent(contentlet, related.getRelationship(), related.isHasParent(), user, respectFrontendRoles);
          Tree newTree = null;
          Set<Tree> uniqueRelationshipSet = new HashSet<Tree>();
 
          Relationship rel = related.getRelationship();
          List<Contentlet> conRels = RelationshipFactory.getAllRelationshipRecords(related.getRelationship(), contentlet, related.isHasParent());
 
          int treePosition = (conRels != null && conRels.size() != 0) ? conRels.size() : 1 ;
          int positionInParent = 1;
         
          for (Contentlet c : related.getRecords()) {
              if (child) {
                  newTree = new Tree(c.getIdentifier(), contentlet.getIdentifier(), rel.getRelationTypeValue(), positionInParent);
              } else {
                  newTree = new Tree(contentlet.getIdentifier(), c.getIdentifier(), rel.getRelationTypeValue(), treePosition);
              }
              positionInParent=positionInParent+1;
             
              if( uniqueRelationshipSet.add(newTree) ) {
                int newTreePosistion = newTree.getTreeOrder();
View Full Code Here

        Structure st = StructureCache.getStructureByInode(contentlet.getStructureInode());
        ContentletRelationships relationshipsData = new ContentletRelationships(contentlet);
        List<ContentletRelationshipRecords> relationshipsRecords = new ArrayList<ContentletRelationshipRecords> ();
        relationshipsData.setRelationshipsRecords(relationshipsRecords);
        for(Entry<Relationship, List<Contentlet>> relEntry : contentRelationships.entrySet()) {
            Relationship relationship = (Relationship) relEntry.getKey();
            boolean hasParent = RelationshipFactory.isParentOfTheRelationship(relationship, st);
            ContentletRelationshipRecords records = relationshipsData.new ContentletRelationshipRecords(relationship, hasParent);
            records.setRecords(relEntry.getValue());
            relationshipsRecords.add(records);
        }
View Full Code Here

        Structure st = StructureCache.getStructureByInode(contentlet.getStructureInode());
        ContentletRelationships relationshipsData = new ContentletRelationships(contentlet);
        List<ContentletRelationshipRecords> relationshipsRecords = new ArrayList<ContentletRelationshipRecords> ();
        relationshipsData.setRelationshipsRecords(relationshipsRecords);
        for(Entry<Relationship, List<Contentlet>> relEntry : contentRelationships.entrySet()) {
            Relationship relationship = (Relationship) relEntry.getKey();
            boolean hasParent = RelationshipFactory.isParentOfTheRelationship(relationship, st);
            ContentletRelationshipRecords records = relationshipsData.new ContentletRelationshipRecords(relationship, hasParent);
            records.setRecords(relEntry.getValue());
            relationshipsRecords.add(records);
        }
View Full Code Here

        Structure st = StructureCache.getStructureByInode(contentlet.getStructureInode());
        ContentletRelationships relationshipsData = new ContentletRelationships(contentlet);
        List<ContentletRelationshipRecords> relationshipsRecords = new ArrayList<ContentletRelationshipRecords> ();
        relationshipsData.setRelationshipsRecords(relationshipsRecords);
        for(Entry<Relationship, List<Contentlet>> relEntry : contentRelationships.entrySet()) {
            Relationship relationship = (Relationship) relEntry.getKey();
            boolean hasParent = RelationshipFactory.isParentOfTheRelationship(relationship, st);
            ContentletRelationshipRecords records = relationshipsData.new ContentletRelationshipRecords(relationship, hasParent);
            records.setRecords(relEntry.getValue());
        }
        validateContentlet(contentlet, relationshipsData, cats);
View Full Code Here

    }
    if (contentRelationships != null) {
      List<ContentletRelationshipRecords> records = contentRelationships
          .getRelationshipsRecords();
      for (ContentletRelationshipRecords cr : records) {
        Relationship rel = cr.getRelationship();
        List<Contentlet> cons = cr.getRecords();
        if (cons == null) {
          cons = new ArrayList<Contentlet>();
        }
       
        //There is a case when the Relationship is between same structures
        //We need to validate that case
        boolean isRelationshipParent = true;
       
        if(rel.getParentStructureInode().equalsIgnoreCase(rel.getChildStructureInode())){
          if(!cr.isHasParent()){
            isRelationshipParent = false;
          }
        }
       
        // if i am the parent
        if (rel.getParentStructureInode().equalsIgnoreCase(stInode) && isRelationshipParent) {
          if (rel.isChildRequired() && cons.isEmpty()) {
            hasError = true;
            cve.addRequiredRelationship(rel, cons);
          }
          for (Contentlet con : cons) {
            try {
              List<Contentlet> relatedCon = getRelatedContent(
                  con, rel, APILocator.getUserAPI()
                      .getSystemUser(), true);
              if (rel.getCardinality() == 0
                  && relatedCon.size() > 0
                  && !relatedCon.get(0).getIdentifier()
                      .equals(contentlet.getIdentifier())) {
                hasError = true;
                cve.addBadCardinalityRelationship(rel, cons);
              }
              if (!con.getStructureInode().equalsIgnoreCase(
                  rel.getChildStructureInode())) {
                hasError = true;
                cve.addInvalidContentRelationship(rel, cons);
              }
            } catch (DotSecurityException e) {
              Logger.error(this, "Unable to get system user", e);
            } catch (DotDataException e) {
              Logger.error(this, "Unable to get system user", e);
            }
          }
        } else if (rel.getChildStructureInode().equalsIgnoreCase(
            stInode)) {
          if (rel.isParentRequired() && cons.isEmpty()) {
            hasError = true;
            cve.addRequiredRelationship(rel, cons);
          }
          if (rel.getCardinality() == 0 && cons.size() > 1) {
            hasError = true;
            cve.addBadCardinalityRelationship(rel, cons);
          }
          for (Contentlet con : cons) {
            if (!con.getStructureInode().equalsIgnoreCase(
                rel.getParentStructureInode())) {
              hasError = true;
              cve.addInvalidContentRelationship(rel, cons);
            }
          }
        } else {
View Full Code Here

        c2 = APILocator.getContentletAPI().checkin(c2, sysuser, false);
       
        APILocator.getContentletAPI().isInodeIndexed(c1.getInode());
        APILocator.getContentletAPI().isInodeIndexed(c2.getInode());
       
        Relationship rel=new Relationship(st1,st2,"st1"+salt,"st2"+salt,0,false,false);
        RelationshipFactory.saveRelationship(rel);
       
        ClientResponse response=contRes.path("/publish/1")
                .type(MediaType.APPLICATION_JSON_TYPE)
                .header(authheader, authvalue).put(ClientResponse.class,
                    new JSONObject()
                        .put("stName", st1.getVelocityVarName())
                        .put(title1.getVelocityVarName(), "a simple title")
                        .put(rel.getRelationTypeValue(), "+structureName:"+st2.getVelocityVarName())
                        .toString());
        Assert.assertEquals(200, response.getStatus());
       
        Thread.sleep(2000); // wait for relation fields update
       
View Full Code Here

      // Get the contentlet structure

      String commentStructureName = commentsStructure.getName().replaceAll("\\s", "_").replaceAll("[^a-zA-Z0-9\\_]", "");

      // Create the relationship
      Relationship relationship = new Relationship();
      relationship.setCardinality(0);
      relationship.setChildRelationName("Parent Comment");
      relationship.setParentRelationName("Replies");
      relationship.setChildStructureInode(commentsStructure.getInode());
      relationship.setParentStructureInode(commentsStructure.getInode());
      relationship.setRelationTypeValue(commentStructureName + "-" + commentStructureName);
      relationship.setParentRequired(false);
      relationship.setChildRequired(false);
      RelationshipFactory.saveRelationship(relationship);
    }
  }
View Full Code Here

    setForward(req, "portlet.ext.structure.edit_relationship");   
  }
 
  private void _retrieveRelationship(ActionForm form,ActionRequest req, ActionResponse res)
  {
    Relationship relationship = new Relationship();
    String inodeString = req.getParameter("inode");
    if(InodeUtils.isSet(inodeString))
    {
      relationship = RelationshipFactory.getRelationshipByInode(inodeString);
    }
    else
    {
      relationship = new Relationship ();
    }
   
    if(relationship.isFixed()){
      String message = "warning.object.isfixed";
      SessionMessages.add(req, "message", message);
    }
   
    req.setAttribute(WebKeys.Relationship.RELATIONSHIP_EDIT,relationship);
View Full Code Here

    try
    {
      String cmd = req.getParameter(Constants.CMD);
      if ((cmd == null) || !cmd.equals(Constants.ADD)) {
        RelationshipForm relationshipForm = (RelationshipForm) form;
        Relationship relationship = (Relationship) req.getAttribute(WebKeys.Relationship.RELATIONSHIP_EDIT);
           
        //Copy properties to the form
        BeanUtils.copyProperties(relationshipForm, relationship);
      }
     
View Full Code Here

TOP

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

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.