1 package com.dotmarketing.portlets.structure.model; 2 3 import java.util.List ; 4 5 import com.dotmarketing.beans.Inode; 6 import com.dotmarketing.beans.Tree; 7 import com.dotmarketing.factories.InodeFactory; 8 import com.dotmarketing.factories.TreeFactory; 9 import com.dotmarketing.portlets.entities.model.Entity; 10 import com.dotmarketing.portlets.structure.factories.FieldFactory; 11 import com.dotmarketing.portlets.structure.factories.StructureFactory; 12 import com.dotmarketing.util.WebKeys; 13 14 15 public class Structure extends Inode 16 { 17 18 private static final long serialVersionUID = 1L; 19 private String name; 20 private String description; 21 private boolean defaultStructure; 22 private String reviewInterval; 23 private String reviewerRole; 24 25 public Structure () { 26 super.setType("structure"); 27 } 28 29 public boolean isDefaultStructure() { 30 return defaultStructure; 31 } 32 public void setDefaultStructure(boolean defaultStructure) { 33 this.defaultStructure = defaultStructure; 34 } 35 public String getDescription() { 36 return description; 37 } 38 public void setDescription(String description) { 39 this.description = description; 40 } 41 public String getName() { 42 return name; 43 } 44 public void setName(String name) { 45 this.name = name; 46 } 47 48 public void delete() 49 { 50 boolean recursive = true; 51 delete(recursive); 52 } 53 54 public void delete(boolean recursive) 55 { 56 if(recursive) 57 { 58 List list = FieldFactory.getFieldByStructureType(inode); 59 for(int i = 0;i < list.size();i++) 60 { 61 Field field = (Field) list.get(i); 62 field.delete(); 63 } 64 } 65 StructureFactory.deleteStructure(this); 66 } 67 71 public List <Field> getFields() 72 { 73 return FieldFactory.getFieldByStructureType(inode); 74 } 75 76 public Entity getEntity() 77 { 78 Entity entity = (Entity) InodeFactory.getParentOfClassByRelationType(this,Entity.class,WebKeys.Structure.STRUCTURE_ENTITY); 79 80 if(entity.getInode() ==0){ 82 entity.setEntityName(this.getName()); 83 InodeFactory.saveInode(entity); 84 Tree tree = new Tree(); 85 tree.setParent(entity.getInode()); 86 tree.setChild(this.getInode()); 87 tree.setRelationType(WebKeys.Structure.STRUCTURE_ENTITY); 88 TreeFactory.saveTree(tree); 89 } 90 91 92 return entity; 93 } 94 95 public String getReviewerRole() { 96 return reviewerRole; 97 } 98 99 public void setReviewerRole(String reviewerRole) { 100 this.reviewerRole = reviewerRole; 101 } 102 103 public String getReviewInterval() { 104 return reviewInterval; 105 } 106 107 public void setReviewInterval(String reviewInterval) { 108 this.reviewInterval = reviewInterval; 109 } 110 111 public List <Field> getFieldsNoLock() 112 { 113 return FieldFactory.getFieldByStructureTypeNoLock(inode); 114 } 115 116 117 } 118 | Popular Tags |