Package com.dotmarketing.portlets.structure.model

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


  private static RelationshipCache cache = CacheLocator.getRelationshipCache();

    // ### READ ###
    public static Relationship getRelationshipByInode(String inode) {
    Relationship rel = null;
    try {
      rel = cache.getRelationshipByInode(inode);
      if(rel != null)
        return rel;
    } catch (DotCacheException e) {
      Logger.error(RelationshipFactory.class, "Unable to access the cache to obtaion the relationship", e);
    }

    rel = (Relationship) InodeFactory.getInode(inode, Relationship.class);
    if(rel!= null && InodeUtils.isSet(rel.getInode()))
      cache.putRelationshipByInode(rel);
    return rel;
    }
View Full Code Here


    }
        return list;
    }

    public static Relationship getRelationshipByRelationTypeValue(String typeValue) {
    Relationship rel = null;
    try {
      rel = cache.getRelationshipByName(typeValue);
      if(rel != null)
        return rel;
    } catch (DotCacheException e) {
      Logger.error(RelationshipFactory.class, "Unable to access the cache to obtaion the relationship", e);
    }

    rel = (Relationship) InodeFactory.getInodeOfClassByCondition(Relationship.class, "relation_type_value = '"
                + typeValue + "'");
    if(rel!= null && InodeUtils.isSet(rel.getInode()))
      cache.putRelationshipByInode(rel);
    return rel;

    }
View Full Code Here

    HibernateUtil.saveWithPrimaryKey(relationship, inode);
  }   

    // ### DELETE ###
    public static void deleteRelationship(String inode) throws DotHibernateException {
        Relationship relationship = getRelationshipByInode(inode);
        deleteRelationship(relationship);
    }
View Full Code Here

      //Find the relationships and their related contents
      HashMap<Relationship,List<Contentlet>> csvRelationshipRecordsParentOnly = new HashMap<Relationship,List<Contentlet>>();
            HashMap<Relationship,List<Contentlet>> csvRelationshipRecordsChildOnly = new HashMap<Relationship,List<Contentlet>>();
      HashMap<Relationship,List<Contentlet>> csvRelationshipRecords = new HashMap<Relationship,List<Contentlet>>();
      for (Integer column : relationships.keySet()) {
        Relationship relationship = relationships.get(column);
        String relatedQuery = line[column];
        List<Contentlet> relatedContentlets = new ArrayList<Contentlet>();
        boolean error = false;
        if(UtilMethods.isSet(relatedQuery))
        {
View Full Code Here

     * @throws DotSecurityException
     * @throws DotDataException
     * @return Returns empty List if no results are found
     */
    public static List<Contentlet> pullRelated(String relationshipName, String contentletIdentifier, String condition, boolean pullParents, int limit, String sort, User user, String tmDate) { 
      Relationship rel = RelationshipFactory.getRelationshipByRelationTypeValue(relationshipName);
      String relNameForQuery = "";
      if(rel.getParentStructureInode().equals(rel.getChildStructureInode())){
        if(pullParents){
          relNameForQuery = relationshipName.trim() + "-child";
        }else{
          relNameForQuery = relationshipName.trim() + "-parent";
        }
      }
     
      if(!UtilMethods.isSet(relNameForQuery))//DOTCMS-5328
        relNameForQuery = rel.getRelationTypeValue();
     
      contentletIdentifier = RecurrenceUtil.getBaseEventIdentifier(contentletIdentifier);
     
           
      String pullquery = "+type:content +" + relNameForQuery + ":" + contentletIdentifier;
View Full Code Here

     * @return
     * @throws DotHibernateException
     */
    protected static Relationship createRelationShip ( String parentStructureInode, String childStrunctureInode, boolean required ) throws DotHibernateException {

        Relationship relationship = new Relationship();
        //Set Parent Info
        relationship.setParentStructureInode( parentStructureInode );
        relationship.setParentRelationName( "parent" );
        relationship.setParentRequired( required );
        //Set Child Info
        relationship.setChildStructureInode( childStrunctureInode );
        relationship.setChildRelationName( "child" );
        relationship.setChildRequired( required );
        //Set general info
        relationship.setRelationTypeValue( "parent-child" );
        relationship.setCardinality( 0 );

        //Save it
        RelationshipFactory.saveRelationship( relationship );

        return relationship;
View Full Code Here

        //Now a new test contentlets
        Contentlet parentContentlet = createContentlet( testStructure, null, false );
        Contentlet childContentlet = createContentlet( testStructure, null, false );

        //Create the relationship
        Relationship testRelationship = createRelationShip( testStructure, false );

        //Create the contentlet relationships
        List<Contentlet> contentRelationships = new ArrayList<Contentlet>();
        contentRelationships.add( childContentlet );
View Full Code Here

        //Now a new test contentlets
        Contentlet parentContentlet = createContentlet( testStructure, null, false );
        Contentlet childContentlet = createContentlet( testStructure, null, false );

        //Create the relationship
        Relationship testRelationship = createRelationShip( testStructure, false );

        //Create the contentlet relationships
        List<Contentlet> contentRelationships = new ArrayList<Contentlet>();
        contentRelationships.add( childContentlet );
        ContentletRelationships contentletRelationships = createContentletRelationships( testRelationship, parentContentlet, testStructure, contentRelationships );
View Full Code Here

        //Now a new test contentlets
        Contentlet parentContentlet = createContentlet( testStructure, null, false );
        Contentlet childContentlet = createContentlet( testStructure, null, false );

        //Create the relationship
        Relationship testRelationship = createRelationShip( testStructure, false );

        //Create the contentlet relationships
        List<Contentlet> contentRelationships = new ArrayList<Contentlet>();
        contentRelationships.add( childContentlet );
        ContentletRelationships contentletRelationships = createContentletRelationships( testRelationship, parentContentlet, testStructure, contentRelationships );
View Full Code Here

        //Now a new test contentlets
        Contentlet parentContentlet = createContentlet( testStructure, null, false );
        Contentlet childContentlet = createContentlet( testStructure, null, false );

        //Create the relationship
        Relationship testRelationship = createRelationShip( testStructure, false );

        //Create the contentlet relationships
        List<Contentlet> contentRelationships = new ArrayList<Contentlet>();
        contentRelationships.add( childContentlet );
        ContentletRelationships contentletRelationships = createContentletRelationships( testRelationship, parentContentlet, testStructure, contentRelationships );

        //Relate contents to our test contentlet
        for ( ContentletRelationships.ContentletRelationshipRecords contentletRelationshipRecords : contentletRelationships.getRelationshipsRecords() ) {
            //Testing the relate content...
            contentletAPI.relateContent( parentContentlet, contentletRelationshipRecords, user, false );
        }

        //Try to find the related Contentlet
        //List<Contentlet> foundContentlets = contentletAPI.getRelatedContent( parentContentlet, testRelationship, user, false );//TODO: This is not the correct method to test the relateContent?? (relateContent and getRelatedContent..., is should, some how it does work for me....)

        /*//Validations
        assertTrue( foundContentlets != null && !foundContentlets.isEmpty() );*/

        //Verify if the content was related
        Tree tree = TreeFactory.getTree( parentContentlet.getIdentifier(), childContentlet.getIdentifier(), testRelationship.getRelationTypeValue() );

        //Validations
        assertNotNull( tree );
        assertNotNull( tree.getParent() );
        assertNotNull( tree.getChild() );
        assertEquals( tree.getParent(), parentContentlet.getIdentifier() );
        assertEquals( tree.getChild(), childContentlet.getIdentifier() );
        assertEquals( tree.getRelationType(), testRelationship.getRelationTypeValue() );
    }
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.