1 package com.dotmarketing.portlets.structure.model; 2 3 import java.util.ArrayList ; 4 import java.util.Collections ; 5 import java.util.List ; 6 7 import com.dotmarketing.comparators.ContentComparator; 8 import com.dotmarketing.portlets.contentlet.model.Contentlet; 9 10 11 16 public class ContentletRelationships 17 { 18 19 private static final long serialVersionUID = 1L; 20 21 private Contentlet contentlet; 22 private List <ContentletRelationshipRecords> relationshipsRecords; 23 24 25 29 public ContentletRelationships(Contentlet contentlet, List <ContentletRelationshipRecords> relationshipsRecords) { 30 super(); 31 this.contentlet = contentlet; 32 this.relationshipsRecords = relationshipsRecords; 33 } 34 35 36 39 public ContentletRelationships(Contentlet contentlet) { 40 this.contentlet = contentlet; 41 this.relationshipsRecords = new ArrayList <ContentletRelationshipRecords> (); 42 } 43 44 45 48 public List <ContentletRelationshipRecords> getRelationshipsRecords() { 49 return relationshipsRecords; 50 } 51 54 public void setRelationshipsRecords( 55 List <ContentletRelationshipRecords> relationshipsRecords) { 56 this.relationshipsRecords = relationshipsRecords; 57 } 58 61 public Contentlet getContentlet() { 62 return contentlet; 63 } 64 67 public void setContentlet(Contentlet contentlet) { 68 this.contentlet = contentlet; 69 } 70 71 public class ContentletRelationshipRecords { 72 73 private Relationship relationship; 74 private List <Contentlet> records; 75 private boolean hasParent; 76 77 80 public ContentletRelationshipRecords(Relationship relationship, boolean hasParent) { 81 super(); 82 this.relationship = relationship; 83 this.records = new ArrayList <Contentlet> (); 84 this.hasParent = hasParent; 85 } 86 87 88 91 public boolean isHasParent() { 92 return hasParent; 93 } 94 95 96 99 public void setHasParent(boolean hasParent) { 100 this.hasParent = hasParent; 101 } 102 103 104 107 public List <Contentlet> getRecords() { 108 return records; 109 } 110 113 public void setRecords(List <Contentlet> records) { 114 this.records = records; 115 } 116 119 public Relationship getRelationship() { 120 return relationship; 121 } 122 125 public void setRelationship(Relationship relationship) { 126 this.relationship = relationship; 127 } 128 129 public void reorderRecords(String field) { 130 131 String fieldContentletName = null; 132 133 Structure st = contentlet.getStructure(); 134 List <Field> fields = st.getFields(); 135 for (Field f : fields) { 136 if (f.getFieldName().equals(field)) { 137 fieldContentletName = f.getFieldContentlet(); 138 break; 139 } 140 } 141 142 if (fieldContentletName != null) 143 Collections.sort(records, new ContentComparator(fieldContentletName)); 144 } 145 } 146 147 148 } 149 | Popular Tags |