Source Code Cross Referenced for BasicCitationService.java in  » ERP-CRM-Financial » sakai » org » sakaiproject » citation » impl » 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.citation.impl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**********************************************************************************
002:         * $URL: https://source.sakaiproject.org/svn/citations/tags/sakai_2-4-1/citations-impl/impl/src/java/org/sakaiproject/citation/impl/BasicCitationService.java $
003:         * $Id: BasicCitationService.java 22624 2007-03-14 20:17:21Z jimeng@umich.edu $
004:         ***********************************************************************************
005:         *
006:         * Copyright (c) 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.citation.impl;
021:
022:        import java.util.Collection;
023:        import java.util.Hashtable;
024:        import java.util.Iterator;
025:        import java.util.List;
026:        import java.util.Map;
027:        import java.util.Set;
028:        import java.util.Stack;
029:        import java.util.Vector;
030:
031:        import org.sakaiproject.citation.api.Citation;
032:        import org.sakaiproject.citation.api.CitationCollection;
033:        import org.sakaiproject.citation.api.Schema;
034:        import org.sakaiproject.citation.impl.BaseCitationService.BasicCitationCollection;
035:        import org.sakaiproject.entity.api.Entity;
036:        import org.sakaiproject.entity.api.HttpAccess;
037:        import org.sakaiproject.entity.api.Reference;
038:        import org.sakaiproject.entity.api.ResourceProperties;
039:        import org.w3c.dom.Document;
040:        import org.w3c.dom.Element;
041:
042:        /**
043:         * This is a test class to implement a concrete CitationService using the Storage interface to define the 
044:         * interactions that will be needed when we do a DB implementation.  This version uses hashtables to 
045:         * store the java objects in memory, rather than serializing them and putting them in a persistent store.
046:         */
047:        public class BasicCitationService extends BaseCitationService {
048:            public class BasicCitationStorage implements  Storage {
049:                protected Map m_collections;
050:                protected Map m_citations;
051:                protected Map m_schemas;
052:
053:                /**
054:                 */
055:                public BasicCitationStorage() {
056:                    super ();
057:                    m_collections = new Hashtable();
058:                    m_citations = new Hashtable();
059:                    m_schemas = new Hashtable();
060:                }
061:
062:                /* (non-Javadoc)
063:                 * @see org.sakaiproject.citation.impl.BaseCitationService.Storage#open()
064:                 */
065:                public void open() {
066:                }
067:
068:                /* (non-Javadoc)
069:                 * @see org.sakaiproject.citation.impl.BaseCitationService.Storage#close()
070:                 */
071:                public void close() {
072:                    m_collections.clear();
073:                    m_collections = null;
074:
075:                    m_citations.clear();
076:                    m_citations = null;
077:
078:                    m_schemas.clear();
079:                    m_schemas = null;
080:
081:                }
082:
083:                /* (non-Javadoc)
084:                 * @see org.sakaiproject.citation.impl.BaseCitationService.Storage#getCitation(java.lang.String)
085:                 */
086:                public Citation getCitation(String citationId) {
087:                    return (Citation) m_citations.get(citationId);
088:                }
089:
090:                /* (non-Javadoc)
091:                 * @see org.sakaiproject.citation.impl.BaseCitationService.Storage#getCollection(java.lang.String)
092:                 */
093:                public CitationCollection getCollection(String collectionId) {
094:                    return (CitationCollection) m_collections.get(collectionId);
095:                }
096:
097:                /* (non-Javadoc)
098:                 * @see org.sakaiproject.citation.impl.BaseCitationService.Storage#getSchema(java.lang.String)
099:                 */
100:                public Schema getSchema(String schemaId) {
101:                    return (Schema) m_schemas.get(schemaId);
102:                }
103:
104:                /* (non-Javadoc)
105:                 * @see org.sakaiproject.citation.impl.BaseCitationService.Storage#getSchemaNames()
106:                 */
107:                public Collection getSchemaNames() {
108:                    return m_schemas.keySet();
109:                }
110:
111:                /* (non-Javadoc)
112:                 * @see org.sakaiproject.citation.impl.BaseCitationService.Storage#getSchemas()
113:                 */
114:                public List getSchemas() {
115:                    List list = new Vector();
116:                    Iterator it = m_schemas.keySet().iterator();
117:                    while (it.hasNext()) {
118:                        String key = (String) it.next();
119:                        Schema schema = (Schema) m_schemas.get(key);
120:                        {
121:                            list.add(new BasicSchema(schema));
122:                        }
123:                    }
124:                    return list;
125:                }
126:
127:                /* (non-Javadoc)
128:                 * @see org.sakaiproject.citation.impl.BaseCitationService.Storage#putSchema(org.sakaiproject.citation.api.Schema)
129:                 */
130:                public Schema addSchema(Schema schema) {
131:                    m_schemas.put(schema.getIdentifier(), schema);
132:                    return schema;
133:                }
134:
135:                /* (non-Javadoc)
136:                 * @see org.sakaiproject.citation.impl.BaseCitationService.Storage#putSchemas(java.util.Collection)
137:                 */
138:                public void putSchemas(Collection schemas) {
139:                    Iterator it = schemas.iterator();
140:                    while (it.hasNext()) {
141:                        Object obj = it.next();
142:                        if (obj instanceof  Schema) {
143:                            m_schemas.put(((Schema) obj).getIdentifier(), obj);
144:                        }
145:                    }
146:
147:                }
148:
149:                /* (non-Javadoc)
150:                 * @see org.sakaiproject.citation.impl.BaseCitationService.Storage#checkCitation(java.lang.String)
151:                 */
152:                public boolean checkCitation(String citationId) {
153:                    return this .m_citations.containsKey(citationId);
154:                }
155:
156:                /* (non-Javadoc)
157:                 * @see org.sakaiproject.citation.impl.BaseCitationService.Storage#checkCollection(java.lang.String)
158:                 */
159:                public boolean checkCollection(String collectionId) {
160:                    return this .m_collections.containsKey(collectionId);
161:                }
162:
163:                /* (non-Javadoc)
164:                 * @see org.sakaiproject.citation.impl.BaseCitationService.Storage#checkSchema(java.lang.String)
165:                 */
166:                public boolean checkSchema(String schemaId) {
167:                    return this .m_schemas.containsKey(schemaId);
168:                }
169:
170:                /* (non-Javadoc)
171:                 * @see org.sakaiproject.citation.impl.BaseCitationService.Storage#listSchemas()
172:                 */
173:                public List listSchemas() {
174:                    Set names = this .m_schemas.keySet();
175:
176:                    return new Vector(names);
177:                }
178:
179:                /* (non-Javadoc)
180:                 * @see org.sakaiproject.citation.impl.BaseCitationService.Storage#putCollection(java.util.Map, java.util.List)
181:                 */
182:                public CitationCollection addCollection(Map attributes,
183:                        List citations) {
184:                    // need to create a collection (referred to below as "edit")
185:                    BasicCitationCollection edit = new BasicCitationCollection(
186:                            attributes, citations);
187:
188:                    this .m_collections.put(edit.getId(), edit);
189:
190:                    return edit;
191:                }
192:
193:                /* (non-Javadoc)
194:                 * @see org.sakaiproject.citation.impl.BaseCitationService.Storage#removeCitation(org.sakaiproject.citation.api.CitationEdit)
195:                 */
196:                public void removeCitation(Citation edit) {
197:                    this .m_citations.remove(edit.getId());
198:                }
199:
200:                /* (non-Javadoc)
201:                 * @see org.sakaiproject.citation.impl.BaseCitationService.Storage#removeCollection(org.sakaiproject.citation.api.CitationCollectionEdit)
202:                 */
203:                public void removeCollection(CitationCollection edit) {
204:                    this .m_collections.remove(edit.getId());
205:                }
206:
207:                /* (non-Javadoc)
208:                 * @see org.sakaiproject.citation.impl.BaseCitationService.Storage#updateSchema(org.sakaiproject.citation.api.Schema)
209:                 */
210:                public void updateSchema(Schema schema) {
211:                    this .m_schemas.put(schema.getIdentifier(), schema);
212:                }
213:
214:                /* (non-Javadoc)
215:                 * @see org.sakaiproject.citation.impl.BaseCitationService.Storage#updateSchemas(java.util.Collection)
216:                 */
217:                public void updateSchemas(Collection schemas) {
218:                    Iterator it = schemas.iterator();
219:                    while (it.hasNext()) {
220:                        Schema schema = (Schema) it.next();
221:                        this .m_schemas.put(schema.getIdentifier(), schema);
222:                    }
223:                }
224:
225:                /* (non-Javadoc)
226:                 * @see org.sakaiproject.citation.impl.BaseCitationService.Storage#saveCitation(org.sakaiproject.citation.api.Citation)
227:                 */
228:                public void saveCitation(Citation edit) {
229:                    this .m_citations.put(edit.getId(), edit);
230:                }
231:
232:                /* (non-Javadoc)
233:                 * @see org.sakaiproject.citation.impl.BaseCitationService.Storage#saveCollection(java.util.Collection)
234:                 */
235:                public void saveCollection(CitationCollection collection) {
236:                    this .m_collections.put(collection.getId(), collection);
237:                }
238:
239:                /* (non-Javadoc)
240:                 * @see org.sakaiproject.citation.impl.BaseCitationService.Storage#addCitation(java.lang.String)
241:                 */
242:                public Citation addCitation(String mediatype) {
243:                    BasicCitation citation = new BasicCitation(mediatype);
244:                    this .m_citations.put(citation.getId(), citation);
245:                    return citation;
246:                }
247:
248:                /* (non-Javadoc)
249:                 * @see org.sakaiproject.citation.impl.BaseCitationService.Storage#removeSchema(org.sakaiproject.citation.api.Schema)
250:                 */
251:                public void removeSchema(Schema schema) {
252:                    m_schemas.remove(schema.getIdentifier());
253:
254:                }
255:
256:                public CitationCollection copyAll(String collectionId) {
257:                    BasicCitationCollection original = (BasicCitationCollection) this .m_collections
258:                            .get(collectionId);
259:                    CitationCollection copy = null;
260:
261:                    if (original != null) {
262:                        copy = new BasicCitationCollection();
263:                        Iterator it = original.iterator();
264:                        while (it.hasNext()) {
265:                            BasicCitation citation = (BasicCitation) it.next();
266:                            BasicCitation newCite = new BasicCitation();
267:                            newCite.copy(citation);
268:                            copy.add(newCite);
269:                            m_citations.put(newCite.getId(), newCite);
270:                        }
271:                        m_collections.put(copy.getId(), copy);
272:                    }
273:
274:                    return copy;
275:                }
276:
277:            }
278:
279:            /* (non-Javadoc)
280:             * @see org.sakaiproject.citation.impl.BaseCitationService#newStorage()
281:             */
282:            public Storage newStorage() {
283:                return new BasicCitationStorage();
284:            }
285:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.