001: /**********************************************************************************
002: * $URL:https://source.sakaiproject.org/svn/osp/trunk/presentation/api/src/java/org/theospi/portfolio/presentation/model/TemplateFileRef.java $
003: * $Id:TemplateFileRef.java 9134 2006-05-08 20:28:42Z chmaurer@iupui.edu $
004: ***********************************************************************************
005: *
006: * Copyright (c) 2005, 2006 The Sakai Foundation.
007: *
008: * Licensed under the Educational Community License, Version 1.0 (the "License");
009: * you may not use this file except in compliance with the License.
010: * You may obtain a copy of the License at
011: *
012: * http://www.opensource.org/licenses/ecl1.php
013: *
014: * Unless required by applicable law or agreed to in writing, software
015: * distributed under the License is distributed on an "AS IS" BASIS,
016: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: * See the License for the specific language governing permissions and
018: * limitations under the License.
019: *
020: **********************************************************************************/package org.theospi.portfolio.presentation.model;
021:
022: import java.io.Serializable;
023:
024: import org.apache.commons.logging.Log;
025: import org.apache.commons.logging.LogFactory;
026: import org.sakaiproject.component.cover.ComponentManager;
027: import org.sakaiproject.metaobj.shared.mgt.IdManager;
028: import org.sakaiproject.metaobj.shared.model.IdentifiableObject;
029: import org.theospi.portfolio.presentation.PresentationManager;
030: import org.theospi.portfolio.shared.mgt.ArtifactUserType;
031: import org.theospi.portfolio.shared.model.Node;
032:
033: /** @author Hibernate CodeGenerator */
034: public class TemplateFileRef extends IdentifiableObject implements
035: Serializable {
036: protected final transient Log logger = LogFactory
037: .getLog(getClass());
038:
039: //private ArtifactUserType file;
040: private String fileId;
041: private String fileType;
042:
043: //private transient Artifact cachedArtifact = null;
044: private transient String artifactName = null;
045: private transient String action;
046:
047: /** nullable persistent field */
048: private String usage;
049:
050: private transient PresentationTemplate presentationTemplate;
051:
052: static final long serialVersionUID = -6220810277272518156l;
053:
054: /** full constructor */
055: public TemplateFileRef(ArtifactUserType file, String usage,
056: PresentationTemplate presentationTemplate) {
057: this .usage = usage;
058: this .presentationTemplate = presentationTemplate;
059: }
060:
061: /** default constructor */
062: public TemplateFileRef() {
063: // todo 8/10
064: // setFile(new ArtifactUserType());
065: //getFile().setHome("fileArtifact");
066: }
067:
068: /** minimal constructor */
069: public TemplateFileRef(PresentationTemplate presentationTemplate) {
070: this .presentationTemplate = presentationTemplate;
071: }
072:
073: public String getAction() {
074: return action;
075: }
076:
077: public void setAction(String action) {
078: this .action = action;
079: }
080:
081: // public ArtifactUserType getFile() {
082: // return this.file;
083: // }
084: //
085: // public void setFile(ArtifactUserType file) {
086: // this.cachedArtifact = null;
087: // this.file = file;
088: // }
089:
090: public String getUsage() {
091: return this .usage;
092: }
093:
094: public void setUsage(String use) {
095: this .usage = use;
096: }
097:
098: public PresentationTemplate getPresentationTemplate() {
099: return this .presentationTemplate;
100: }
101:
102: public void setPresentationTemplate(
103: PresentationTemplate presentationTemplate) {
104: this .presentationTemplate = presentationTemplate;
105: }
106:
107: private Node getNode() {
108: return getPresentationManager().getNode(
109: getIdManager().getId(fileId));
110: }
111:
112: public String getArtifactName() {
113: if (artifactName == null) {
114: if (getNode() != null) {
115: artifactName = getNode().getDisplayName();
116: }
117: }
118:
119: return artifactName;
120: }
121:
122: public void setArtifactName(String artifactName) {
123: this .artifactName = artifactName;
124: }
125:
126: public String toString() {
127: return "TemplateFileRef{" + "id=" + getId() + ", fileId="
128: + fileId + ", usage='" + usage + "'"
129: + ", presentationTemplate=" + presentationTemplate
130: + "}";
131: }
132:
133: public int hashCode() {
134: if (getId() != null) {
135: return getId().hashCode();
136: }
137:
138: if (fileId != null) {
139: return fileId.hashCode();
140: } else {
141: return 0;
142: }
143: }
144:
145: /*
146: protected void setupFile() {
147: if (fileType != null && fileId != null) {
148: setFile(new ArtifactUserType(fileId, fileType));
149: }
150: }
151: */
152: public String getFileId() {
153: //return getFile().getId().getValue();
154: return this .fileId;
155: }
156:
157: public void setFileId(String fileId) {
158: this .fileId = fileId;
159: //setupFile();
160: }
161:
162: public String getFileType() {
163: //return getFile().getHome().getType().getId().getValue();
164: return this .fileType;
165: }
166:
167: public void setFileType(String fileType) {
168: this .fileType = fileType;
169: //setupFile();
170: }
171:
172: public PresentationManager getPresentationManager() {
173: return (PresentationManager) ComponentManager.getInstance()
174: .get("presentationManager");
175: }
176:
177: public IdManager getIdManager() {
178: return (IdManager) ComponentManager.getInstance().get(
179: "idManager");
180: }
181: }
|