KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > pentaho > core > repository > SimpleRuntimeRepository


1 /*
2  * Copyright 2006 Pentaho Corporation. All rights reserved.
3  * This software was developed by Pentaho Corporation and is provided under the terms
4  * of the Mozilla Public License, Version 1.1, or any later version. You may not use
5  * this file except in compliance with the license. If you need a copy of the license,
6  * please go to http://www.mozilla.org/MPL/MPL-1.1.txt. The Original Code is the Pentaho
7  * BI Platform. The Initial Developer is Pentaho Corporation.
8  *
9  * Software distributed under the Mozilla Public License is distributed on an "AS IS"
10  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. Please refer to
11  * the license for the specific language governing your rights and limitations.
12  *
13  * @created Jun 15, 2005
14  * @author James Dixon
15  *
16  */

17 package org.pentaho.core.repository;
18
19 import java.util.Collection JavaDoc;
20 import java.util.List JavaDoc;
21 import org.apache.commons.logging.Log;
22 import org.apache.commons.logging.LogFactory;
23 import org.pentaho.messages.Messages;
24 import org.pentaho.core.session.IPentahoSession;
25 import org.pentaho.core.system.PentahoBase;
26 import org.pentaho.core.system.PentahoSystem;
27 import org.pentaho.core.repository.RepositoryException;
28 import org.pentaho.core.repository.IRuntimeElement;
29 import org.pentaho.core.repository.SimpleRuntimeElement;
30 import org.pentaho.util.UUIDUtil;
31
32 /**
33  *
34  * @author James Dixon
35  *
36  * This is a lightweight version on the runtime repository that will not persist
37  * any runtime elements. This class is intended for simple standalone
38  * applications that do not require workflow
39  */

40 public class SimpleRuntimeRepository extends PentahoBase implements IRuntimeRepository {
41
42     /**
43      *
44      */

45     private static final long serialVersionUID = -6093228119094501691L;
46
47     private static final boolean debug = PentahoSystem.debug;
48
49     private static Log log = LogFactory.getLog(SimpleRuntimeRepository.class);
50
51     private static final ThreadLocal JavaDoc threadSession = new ThreadLocal JavaDoc();
52
53     /**
54      * @return Returns the userSession.
55      */

56     public static IPentahoSession getUserSession() {
57         IPentahoSession userSession = (IPentahoSession) threadSession.get();
58         return userSession;
59     }
60
61     public SimpleRuntimeRepository() {
62
63     }
64
65     public List JavaDoc getMessages() {
66         return null;
67     }
68
69     public static IRuntimeRepository getInstance(IPentahoSession sess) {
70         IRuntimeRepository repo = new SimpleRuntimeRepository();
71         repo.setSession(sess);
72         return repo;
73     }
74
75     public void setSession(IPentahoSession sess) {
76         threadSession.set(sess);
77         genLogIdFromSession(getUserSession());
78     }
79
80     /**
81      * Loads an existing RuntimeElement
82      *
83      * @param instId
84      * The instance Id
85      * @return the RuntimeElement
86      * @throws RepositoryException
87      */

88     public IRuntimeElement loadElementById(String JavaDoc instanceId, Collection JavaDoc allowableReadAttributeNames) throws RepositoryException {
89         if (debug)
90             debug(Messages.getString("RTREPO.DEBUG_CREATE_INSTANCE", instanceId)); //$NON-NLS-1$
91
SimpleRuntimeElement re = new SimpleRuntimeElement(instanceId);
92         return re;
93     }
94
95     /**
96      *
97      * Creates a new RuntimeElement
98      *
99      * @param parId
100      * Parent ID of this instance
101      * @param parType
102      * Parent type of the instance
103      * @return the created runtime element
104      */

105     public IRuntimeElement newRuntimeElement(String JavaDoc parId, String JavaDoc parType, boolean transientOnly) {
106         if (debug)
107             debug(Messages.getString("RTREPO.DEBUG_NEW_ELEMENT_PARENT", parId, parType)); //$NON-NLS-1$
108
String JavaDoc instanceId = UUIDUtil.getUUIDAsString();
109         if (debug)
110             debug(Messages.getString("RTREPO.DEBUG_CREATE_INSTANCE", instanceId)); //$NON-NLS-1$
111
SimpleRuntimeElement re = new SimpleRuntimeElement(instanceId, parId, parType);
112         return re;
113     }
114
115     /**
116      *
117      * Creates a new RuntimeElement
118      *
119      * @param parId
120      * Parent Id of the runtime element
121      * @param parType
122      * Parent type of the runtime element
123      * @param solnId
124      * Solution Id of the element
125      * @return The created runtime element
126      */

127     public IRuntimeElement newRuntimeElement(String JavaDoc parId, String JavaDoc parType, String JavaDoc solnId, boolean transientOnly) {
128         if (debug)
129             debug(Messages.getString("RTREPO.DEBUG_NEW_ELEMENT_PARENT_SOLN", parId, parType, solnId)); //$NON-NLS-1$
130
String JavaDoc instanceId = UUIDUtil.getUUIDAsString();
131         if (debug)
132             debug(Messages.getString("RTREPO.DEBUG_CREATE_INSTANCE", instanceId)); //$NON-NLS-1$
133
SimpleRuntimeElement re = new SimpleRuntimeElement(instanceId, parId, parType, solnId);
134         return re;
135     }
136
137     /* ILogger Needs */
138     public Log getLogger() {
139         return log;
140     }
141
142     public boolean usesHibernate() {
143         return false;
144     }
145
146     public void exitPoint() {
147         
148     }
149     
150 }
151
Popular Tags