Package com.dotmarketing.portlets.structure.model

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


  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;
            }
View Full Code Here


    return false;
  }
 
  private void _deleteRelationship(ActionForm form,ActionRequest req, ActionResponse res) throws DotHibernateException
  {
    Relationship relationship = (Relationship) req.getAttribute(WebKeys.Relationship.RELATIONSHIP_EDIT);
   
    TreeFactory.deleteTreesByRelationType(relationship.getRelationTypeValue());
   
    RelationshipFactory.deleteRelationship(relationship);
   
    String message = "message.relationship.deleted";
    SessionMessages.add(req, "message",message);       
View Full Code Here

  private static final String FACILITY_STRUCTURE_DESCRIPTION = "Facilities";

  private static void initEventEventRelation(Structure eventStructure) throws DotHibernateException {
   
    if(true)return;
    Relationship relationship = RelationshipFactory.getRelationshipByRelationTypeValue("Event-Event");
   
    if (relationship == null) {

      // Create the relationship
      relationship = new Relationship();
      relationship.setCardinality(0);
      relationship.setChildRelationName("Event");
      relationship.setParentRelationName("Event");
      relationship.setChildStructureInode(eventStructure.getInode());
      relationship.setParentStructureInode(eventStructure.getInode());
      relationship.setRelationTypeValue("Event-Event");
      relationship.setParentRequired(false);
      relationship.setChildRequired(false);
      RelationshipFactory.saveRelationship(relationship);

    }
  } 
View Full Code Here

    }
  } 
 
  private static void initBuidlingFacilityRelation(Structure buildingStructure, Structure facilityStructure) throws DotHibernateException {
    if(true)return;
    Relationship relationship = RelationshipFactory.getRelationshipByRelationTypeValue("Building-Facility");
   
    if (relationship == null || !InodeUtils.isSet(relationship.getInode())) {

      // Create the relationship
      relationship = new Relationship();
      relationship.setCardinality(0);
      relationship.setParentRelationName("Building");
      relationship.setChildRelationName("Facility");
      relationship.setParentStructureInode(buildingStructure.getInode());
      relationship.setChildStructureInode(facilityStructure.getInode());
      relationship.setRelationTypeValue("Building-Facility");
      relationship.setParentRequired(true);
      relationship.setChildRequired(false);
      RelationshipFactory.saveRelationship(relationship);

    }
  }
View Full Code Here

    Set<String> keys = req.getParameterMap().keySet();
    ContentletRelationships.ContentletRelationshipRecords contentletRelationshipRecords;
    boolean hasParent;
    String inodesSt;
    String[] inodes;
    Relationship relationship;
    String inode;
    Contentlet contentlet;
    ContentletAPI contentletAPI = APILocator.getContentletAPI();
    List<Contentlet> records = null;
View Full Code Here

        boolean hasParent = key.contains("_P_");
        String inodesSt = (String) req.getParameter(key);

        String[] inodes = inodesSt.split(",");

        Relationship relationship = (Relationship) InodeFactory.getInode(inodes[0], Relationship.class);
        ContentletRelationshipRecords records = relationshipsData.new ContentletRelationshipRecords(relationship, hasParent);
        ArrayList<Contentlet> cons = new ArrayList<Contentlet>();
        for (String inode : inodes) {
          String i = "";
          try{
            i = inode;
          }catch (Exception e) {
            Logger.error(this, "Relationship not a number value : ",e);
          }
          if(relationship.getInode().equalsIgnoreCase(i)){
            continue;
          }
          try{
            cons.add(conAPI.find(inode, user, false));
          }catch(Exception e){
View Full Code Here

    Set<String> keys = contentletFormData.keySet();
    ContentletRelationships.ContentletRelationshipRecords contentletRelationshipRecords;
    boolean hasParent;
    String inodesSt;
    String[] inodes;
    Relationship relationship;
    String inode;
    Contentlet contentlet;
    ContentletAPI contentletAPI = APILocator.getContentletAPI();
    List<Contentlet> records = null;
View Full Code Here

        if(!UtilMethods.isSet(inodesSt)){
          continue;
        }
        String[] inodes = inodesSt.split(",");

        Relationship relationship = (Relationship) InodeFactory.getInode(inodes[0], Relationship.class);
        ContentletRelationshipRecords records = relationshipsData.new ContentletRelationshipRecords(relationship, hasParent);
        ArrayList<Contentlet> cons = new ArrayList<Contentlet>();
        for (String inode : inodes) {
          /*long i = 0;
          try{
            i = Long.valueOf(inode);
          }catch (Exception e) {
            Logger.error(this, "Relationship not a number value : ",e);
          }*/
          if(relationship.getInode().equalsIgnoreCase(inode)){
            continue;
          }
          try{
            cons.add(conAPI.find(inode, user, false));
          }catch(Exception e){
View Full Code Here

    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");
View Full Code Here

      Logger.error(this, "Error trying to obtain the current liferay user from the request.", e);
    }

    Contentlet currentContentlet;
    Contentlet contentletToUnrelate;
    Relationship relationship;
    List<Contentlet> conList = new ArrayList<Contentlet>();
    String resultStr = "Content Unrelated";
    try {
      currentContentlet = conAPI.find(contentletIdentifier, currentUser, false);
      contentletToUnrelate = conAPI.find(identifierToUnrelate, currentUser, false);
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.