1 24 package org.riotfamily.components; 25 26 import java.util.Map ; 27 import java.util.Set ; 28 29 36 public class VersionContainer { 37 38 private Long id; 39 40 private ComponentList liveList; 41 42 private ComponentList previewList; 43 44 private ComponentVersion liveVersion; 45 46 private ComponentVersion previewVersion; 47 48 private Set versions; 49 50 private Set childLists; 51 52 public VersionContainer() { 53 } 54 55 public Long getId() { 56 return this.id; 57 } 58 59 public void setId(Long id) { 60 this.id = id; 61 } 62 63 public ComponentList getList() { 64 return this.previewList != null ? previewList : liveList; 65 } 66 67 public void setList(ComponentList list) { 68 this.liveList = list; 69 this.previewList = list; 70 } 71 72 public ComponentVersion getLiveVersion() { 73 return this.liveVersion; 74 } 75 76 public void setLiveVersion(ComponentVersion liveVersion) { 77 this.liveVersion = liveVersion; 78 if (liveVersion != null) { 79 liveVersion.setContainer(this); 80 } 81 } 82 83 public ComponentVersion getPreviewVersion() { 84 return this.previewVersion; 85 } 86 87 public void setPreviewVersion(ComponentVersion previewVersion) { 88 this.previewVersion = previewVersion; 89 if (previewVersion != null) { 90 previewVersion.setContainer(this); 91 } 92 } 93 94 public Set getVersions() { 95 return this.versions; 96 } 97 98 public void setVersions(Set versions) { 99 this.versions = versions; 100 } 101 102 public Set getChildLists() { 103 return this.childLists; 104 } 105 106 public void setChildLists(Set childLists) { 107 this.childLists = childLists; 108 } 109 110 public ComponentVersion getLatestVersion() { 111 return previewVersion != null ? previewVersion : liveVersion; 112 } 113 114 public boolean isDirty() { 115 return previewVersion != null; 116 } 117 118 public boolean isPublished() { 119 return liveVersion != null; 120 } 121 122 public Map getProperties(boolean preview) { 123 if (preview) { 124 return getLatestVersion().getProperties(); 125 } 126 return liveVersion != null ? liveVersion.getProperties() : null; 127 } 128 129 public String getProperty(String key, boolean preview) { 130 ComponentVersion version = preview ? getLatestVersion() : liveVersion; 131 return version != null ? version.getProperty(key) : null; 132 } 133 134 } 135 | Popular Tags |