Source Code Cross Referenced for StructuredArtifactDefinition.java in  » ERP-CRM-Financial » sakai » org » sakaiproject » metaobj » shared » mgt » home » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » ERP CRM Financial » sakai » org.sakaiproject.metaobj.shared.mgt.home 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**********************************************************************************
002:         * $URL: https://source.sakaiproject.org/svn/metaobj/tags/sakai_2-4-1/metaobj-impl/api-impl/src/java/org/sakaiproject/metaobj/shared/mgt/home/StructuredArtifactDefinition.java $
003:         * $Id: StructuredArtifactDefinition.java 19424 2006-12-12 18:42:54Z chmaurer@iupui.edu $
004:         ***********************************************************************************
005:         *
006:         * Copyright (c) 2004, 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.sakaiproject.metaobj.shared.mgt.home;
021:
022:        import org.sakaiproject.component.cover.ComponentManager;
023:        import org.sakaiproject.metaobj.shared.mgt.IdManager;
024:        import org.sakaiproject.metaobj.shared.mgt.PresentableObjectHome;
025:        import org.sakaiproject.metaobj.shared.model.*;
026:        import org.sakaiproject.metaobj.utils.xml.SchemaFactory;
027:        import org.sakaiproject.metaobj.utils.xml.SchemaNode;
028:
029:        import java.io.ByteArrayInputStream;
030:        import java.io.Serializable;
031:        import java.text.MessageFormat;
032:        import java.util.Date;
033:
034:        /**
035:         * @author chmaurer, jbush
036:         */
037:        public class StructuredArtifactDefinition extends
038:                StructuredArtifactHome implements  Serializable {
039:            public static final int STATE_UNPUBLISHED = 0;
040:            public static final int STATE_WAITING_APPROVAL = 1;
041:            public static final int STATE_PUBLISHED = 2;
042:
043:            private Id id;
044:            private String documentRoot;
045:            private Agent owner;
046:            private Date created = new Date();
047:            private Date modified = new Date();
048:
049:            private transient String decoratedDescription;
050:
051:            /**
052:             * system only SAD's are not available to users to populate via a web form, they are for internal system use only
053:             */
054:            private boolean systemOnly = false;
055:            private String description;
056:            private boolean modifiable = true;
057:            private Id xslConversionFileId;
058:            private String schemaFileName;
059:            private String xslFileName;
060:            private SchemaNode schema;
061:
062:            /**
063:             * should be one of the following states
064:             * <p/>
065:             * unpublished -> active
066:             */
067:            private int siteState;
068:
069:            /**
070:             * should be one of the following states
071:             * <p/>
072:             * unpublished -> waiting for approval-> active
073:             */
074:            private int globalState;
075:
076:            /**
077:             * used during edit process to store whether or not xsl transform is necessary
078:             */
079:            private boolean requiresXslFile = false;
080:
081:            /**
082:             * file id of schema file - used when add/editing artifact homes
083:             */
084:            private Id schemaFile;
085:
086:            /**
087:             * used in publishing web form to set action (publish to site, global, approve, etc)
088:             */
089:            private String action;
090:
091:            private static final MessageFormat format = new MessageFormat(
092:                    "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"0;URL={0}/member/viewArtifact.osp?artifactId={1}&artifactType={2}\">");
093:
094:            public StructuredArtifactDefinition() {
095:                ;
096:            }
097:
098:            public StructuredArtifactDefinition(
099:                    StructuredArtifactDefinitionBean bean) {
100:                this .action = bean.getAction();
101:                this .created = bean.getCreated();
102:                this .description = bean.getDescription();
103:                this .documentRoot = bean.getDocumentRoot();
104:                this .globalState = bean.getGlobalState();
105:                this .id = bean.getId();
106:                this .modifiable = bean.isModifiable();
107:                this .modified = bean.getModified();
108:                this .owner = bean.getOwner();
109:                this .requiresXslFile = bean.getRequiresXslFile();
110:
111:                if (bean.getSchema() != null) {
112:                    SchemaFactory schemaFactory = SchemaFactory.getInstance();
113:                    ByteArrayInputStream in = new ByteArrayInputStream(bean
114:                            .getSchema());
115:
116:                    this .schema = schemaFactory.getSchema(in);
117:                } else {
118:                    this .schema = null;
119:                }
120:
121:                this .schemaFile = bean.getSchemaFile();
122:                this .schemaFileName = bean.getSchemaFileName();
123:                this .siteState = bean.getSiteState();
124:                this .systemOnly = bean.isSystemOnly();
125:                this .xslConversionFileId = bean.getXslConversionFileId();
126:                this .xslFileName = bean.getXslFileName();
127:                this .setSiteId(bean.getSiteId());
128:                this .setExternalType(bean.getExternalType());
129:                this .setInstruction(bean.getInstruction());
130:                this .decoratedDescription = bean.getDecoratedDescription();
131:
132:                if (getId() != null)
133:                    this .setTypeId(getId().getValue());
134:            }
135:
136:            public boolean equals(Object o) {
137:                if (!(o instanceof  StructuredArtifactDefinition)) {
138:                    return false;
139:                }
140:                StructuredArtifactDefinition in = (StructuredArtifactDefinition) o;
141:
142:                if (getId() == null && in.getId() == null) {
143:                    return true;
144:                }
145:                if (getId() == null && in.getId() != null) {
146:                    return false;
147:                }
148:
149:                return getId().equals(in.getId());
150:            }
151:
152:            public Artifact createInstance() {
153:                StructuredArtifact instance = new StructuredArtifact(
154:                        documentRoot, getSchema().getChild(documentRoot));
155:                prepareInstance(instance);
156:                return instance;
157:            }
158:
159:            public void prepareInstance(Artifact object) {
160:                object.setHome(this );
161:                StructuredArtifact xmlObject = (StructuredArtifact) object;
162:                xmlObject.getBaseElement().setName(documentRoot);
163:            }
164:
165:            public String getRootNode() {
166:                return documentRoot;
167:            }
168:
169:            /**
170:             * @return Returns the created.
171:             */
172:            public Date getCreated() {
173:                return created;
174:            }
175:
176:            /**
177:             * @param created The created to set.
178:             */
179:            public void setCreated(Date created) {
180:                this .created = created;
181:            }
182:
183:            /**
184:             * @return Returns the documentRoot.
185:             */
186:            public String getDocumentRoot() {
187:                return documentRoot;
188:            }
189:
190:            /**
191:             * @param documentRoot The documentRoot to set.
192:             */
193:            public void setDocumentRoot(String documentRoot) {
194:                this .documentRoot = documentRoot;
195:            }
196:
197:            /**
198:             * @return Returns the id.
199:             */
200:            public Id getId() {
201:                return id;
202:            }
203:
204:            /**
205:             * @param id The id to set.
206:             */
207:            public void setId(Id id) {
208:                this .id = id;
209:            }
210:
211:            public Date getModified() {
212:                return modified;
213:            }
214:
215:            public void setModified(Date modified) {
216:                this .modified = modified;
217:            }
218:
219:            /**
220:             * @return Returns the owner.
221:             */
222:            public Agent getOwner() {
223:                return owner;
224:            }
225:
226:            /**
227:             * @param owner The owner to set.
228:             */
229:            public void setOwner(Agent owner) {
230:                this .owner = owner;
231:            }
232:
233:            public String getExternalType() {
234:                return super .getExternalType();
235:            }
236:
237:            public void setExternalType(String newType) {
238:                // stub this out... this property should be read only      
239:            }
240:
241:            /**
242:             * @return Returns the schema.
243:             */
244:            public SchemaNode getSchema() {
245:                return schema;
246:                /*      if (getSchemaFile() == null) {
247:                 return null;
248:                 }
249:                 RepositoryNode rNode = (RepositoryNode) getRepositoryManager().getNode(getSchemaFile());
250:                 if (rNode == null) {
251:                 return null;
252:                 }
253:                 SchemaFactory schemaFactory = SchemaFactory.getInstance();
254:                 return schemaFactory.getSchema(rNode.getStream(RepositoryNode.FILE_TYPE));
255:                 */
256:            }
257:
258:            public void setSchema(SchemaNode schema) {
259:                this .schema = schema;
260:            }
261:
262:            /**  todo implement conversion file stuff
263:             public RepositoryNode getXslConversionFileNode() {
264:             return (RepositoryNode) getRepositoryManager().getNode(getXslConversionFileId());
265:             }
266:
267:             public InputStream getXslConversionFileStream(){
268:             return getXslConversionFileNode().getStream();
269:             }
270:             **/
271:
272:            /**
273:             * @return Returns the type.
274:             */
275:            public Type getType() {
276:                Type type = new Type();
277:                if (getId() != null) {
278:                    type.setId(getId());
279:                }
280:                if (getDescription() != null) {
281:                    type.setDescription(getDecoratedDescription());
282:                }
283:                type.setSystemOnly(isSystemOnly());
284:                return type;
285:            }
286:
287:            /**
288:             * @return Returns the systemOnly.
289:             */
290:            public boolean isSystemOnly() {
291:                return systemOnly;
292:            }
293:
294:            /**
295:             * @param systemOnly The systemOnly to set.
296:             */
297:            public void setSystemOnly(boolean systemOnly) {
298:                this .systemOnly = systemOnly;
299:            }
300:
301:            /**
302:             * @return Returns the idManager.
303:             */
304:            public IdManager getIdManager() {
305:                return (IdManager) ComponentManager.getInstance().get(
306:                        "idManager");
307:            }
308:
309:            public PresentableObjectHome getRepositoryHelper() {
310:                return (PresentableObjectHome) ComponentManager.getInstance()
311:                        .get("repositoryHelper");
312:            }
313:
314:            /**
315:             * public StreamStore getStreamStore() {
316:             * return (StreamStore)BeanFactory.getInstance().getBean(
317:             * StreamStore.class.getName(), StreamStore.class);
318:             * }
319:             * <p/>
320:             * public NodeMetadataService getNodeMetadataService() {
321:             * return (NodeMetadataService)BeanFactory.getInstance().getBean(
322:             * NodeMetadataService.class.getName(), NodeMetadataService.class);
323:             * }
324:             */
325:
326:            public String getDescription() {
327:                return description;
328:            }
329:
330:            public void setDescription(String description) {
331:                this .description = description;
332:            }
333:
334:            public boolean isModifiable() {
335:                return modifiable;
336:            }
337:
338:            public boolean getRequiresXslFile() {
339:                return requiresXslFile;
340:            }
341:
342:            public void setRequiresXslFile(boolean requiresXslFile) {
343:                this .requiresXslFile = requiresXslFile;
344:            }
345:
346:            public Id getSchemaFile() {
347:                return schemaFile;
348:            }
349:
350:            public void setSchemaFile(Id schemaFile) {
351:                this .schemaFile = schemaFile;
352:            }
353:
354:            public Id getXslConversionFileId() {
355:                return xslConversionFileId;
356:            }
357:
358:            public void setXslConversionFileId(Id xslConversionFileId) {
359:                this .xslConversionFileId = xslConversionFileId;
360:            }
361:
362:            public String getSchemaFileName() {
363:                return schemaFileName;
364:            }
365:
366:            public void setSchemaFileName(String schemaFileName) {
367:                this .schemaFileName = schemaFileName;
368:            }
369:
370:            public String getXslFileName() {
371:                return xslFileName;
372:            }
373:
374:            public void setXslFileName(String xslFileName) {
375:                this .xslFileName = xslFileName;
376:            }
377:
378:            public int getSiteState() {
379:                return siteState;
380:            }
381:
382:            public void setSiteState(int siteState) {
383:                this .siteState = siteState;
384:            }
385:
386:            public int getGlobalState() {
387:                return globalState;
388:            }
389:
390:            public void setGlobalState(int globalState) {
391:                this .globalState = globalState;
392:            }
393:
394:            /**
395:             * This method doesn't do any authz, it simply checks the state
396:             *
397:             * @return true, if sad can be published to site.
398:             */
399:            public boolean getCanPublish() {
400:                return (siteState == STATE_UNPUBLISHED && globalState != STATE_PUBLISHED);
401:            }
402:
403:            public boolean getCanGlobalPublish() {
404:                return (globalState == STATE_UNPUBLISHED);
405:            }
406:
407:            /**
408:             * This method doesn't do any authz, it simply checks the state
409:             *
410:             * @return true, if sad can be suggested for global publish
411:             */
412:            public boolean getCanSuggestGlobalPublish() {
413:                return (globalState == STATE_UNPUBLISHED);
414:            }
415:
416:            /**
417:             * This method doesn't do any authz, it simply checks the state
418:             *
419:             * @return true, if sad can be published globally
420:             */
421:            public boolean getCanApproveGlobalPublish() {
422:                return (globalState == STATE_WAITING_APPROVAL);
423:            }
424:
425:            public String getAction() {
426:                return action;
427:            }
428:
429:            public void setAction(String action) {
430:                this .action = action;
431:            }
432:
433:            public String getDecoratedDescription() {
434:                return decoratedDescription;
435:            }
436:
437:            public void setDecoratedDescription(String decoratedDescription) {
438:                this.decoratedDescription = decoratedDescription;
439:            }
440:
441:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.