Package com.dotmarketing.portlets.structure.struts

Examples of com.dotmarketing.portlets.structure.struts.RelationshipForm


  {
    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


 
  private boolean _saveRelationship(ActionForm form,ActionRequest req, ActionResponse res)
  {
    try
    {
      RelationshipForm relationshipForm = (RelationshipForm) form;
      Relationship relationship = (Relationship) req.getAttribute(WebKeys.Relationship.RELATIONSHIP_EDIT);
      Structure parentStructure = null;
      Structure childStructure  = null;
      if(InodeUtils.isSet(relationshipForm.getParentStructureInode()) ||
          InodeUtils.isSet(relationshipForm.getChildStructureInode())){
        parentStructure = StructureCache.getStructureByInode(relationshipForm.getParentStructureInode());
        childStructure  = StructureCache.getStructureByInode(relationshipForm.getChildStructureInode());
      }
      if(parentStructure!=null && childStructure!=null){

        if(!relationship.isFixed()){

          String relationshipTypeValue = relationshipForm.getParentRelationName().replaceAll("\\s", "_").replaceAll("[^a-zA-Z0-9\\_]", "") +
          "-" + relationshipForm.getChildRelationName().replaceAll("\\s", "_").replaceAll("[^a-zA-Z0-9\\_]", "");

          String lastRelationshipTypeValue = relationship.getRelationTypeValue();

          //Preserve old tree relationship if the relation name be changed
          if (InodeUtils.isSet(relationship.getInode()) && !relationshipTypeValue.equals(lastRelationshipTypeValue)) {
            DotConnect dc = new DotConnect ();
            dc.setSQL("update tree set relation_type = '" + relationshipTypeValue +
                "' where relation_type = '" + lastRelationshipTypeValue + "'");
            dc.getResult();
          }

          //Copy properties from the form
          BeanUtils.copyProperties(relationship,relationshipForm);

          if (!relationshipTypeValue.equals(relationship.getRelationTypeValue())) {
            Relationship oRel = RelationshipFactory.getRelationshipByRelationTypeValue(relationshipTypeValue);
            if (InodeUtils.isSet(oRel.getInode()) && !oRel.getInode().equalsIgnoreCase(relationship.getInode())) {
              String message = "error.relationship.same.relation.exist";
              SessionMessages.add(req, "error",message);
              return false;
            }

            List<Tree> treesToUpdate = TreeFactory.getTreesByRelationType(relationshipForm.getRelationTypeValue());
            for (Tree theTree : treesToUpdate) {
              theTree.setRelationType(relationshipTypeValue);
            }
            relationship.setRelationTypeValue(relationshipTypeValue);
          }
View Full Code Here

TOP

Related Classes of com.dotmarketing.portlets.structure.struts.RelationshipForm

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.