1 17 package org.pentaho.core.repository; 18 19 import java.util.Collection ; 20 import java.util.List ; 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 40 public class SimpleRuntimeRepository extends PentahoBase implements IRuntimeRepository { 41 42 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 threadSession = new ThreadLocal (); 52 53 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 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 88 public IRuntimeElement loadElementById(String instanceId, Collection allowableReadAttributeNames) throws RepositoryException { 89 if (debug) 90 debug(Messages.getString("RTREPO.DEBUG_CREATE_INSTANCE", instanceId)); SimpleRuntimeElement re = new SimpleRuntimeElement(instanceId); 92 return re; 93 } 94 95 105 public IRuntimeElement newRuntimeElement(String parId, String parType, boolean transientOnly) { 106 if (debug) 107 debug(Messages.getString("RTREPO.DEBUG_NEW_ELEMENT_PARENT", parId, parType)); String instanceId = UUIDUtil.getUUIDAsString(); 109 if (debug) 110 debug(Messages.getString("RTREPO.DEBUG_CREATE_INSTANCE", instanceId)); SimpleRuntimeElement re = new SimpleRuntimeElement(instanceId, parId, parType); 112 return re; 113 } 114 115 127 public IRuntimeElement newRuntimeElement(String parId, String parType, String solnId, boolean transientOnly) { 128 if (debug) 129 debug(Messages.getString("RTREPO.DEBUG_NEW_ELEMENT_PARENT_SOLN", parId, parType, solnId)); String instanceId = UUIDUtil.getUUIDAsString(); 131 if (debug) 132 debug(Messages.getString("RTREPO.DEBUG_CREATE_INSTANCE", instanceId)); SimpleRuntimeElement re = new SimpleRuntimeElement(instanceId, parId, parType, solnId); 134 return re; 135 } 136 137 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 |