code
stringlengths 73
34.1k
| func_name
stringlengths 1
122
|
---|---|
public ObjectReferenceDescriptor getObjectReferenceDescriptorByName(String name)
{
ObjectReferenceDescriptor ord = (ObjectReferenceDescriptor)
getObjectReferenceDescriptorsNameMap().get(name);
//
// BRJ: if the ReferenceDescriptor is not found
// look in the ClassDescriptor referenced by 'super' for it
//
if (ord == null)
{
ClassDescriptor superCld = getSuperClassDescriptor();
if (superCld != null)
{
ord = superCld.getObjectReferenceDescriptorByName(name);
}
}
return ord;
} | getObjectReferenceDescriptorByName |
public CollectionDescriptor getCollectionDescriptorByName(String name)
{
if (name == null)
{
return null;
}
CollectionDescriptor cod = (CollectionDescriptor) getCollectionDescriptorNameMap().get(name);
//
// BRJ: if the CollectionDescriptor is not found
// look in the ClassDescriptor referenced by 'super' for it
//
if (cod == null)
{
ClassDescriptor superCld = getSuperClassDescriptor();
if (superCld != null)
{
cod = superCld.getCollectionDescriptorByName(name);
}
}
return cod;
} | getCollectionDescriptorByName |
public ClassDescriptor getSuperClassDescriptor()
{
if (!m_superCldSet)
{
if(getBaseClass() != null)
{
m_superCld = getRepository().getDescriptorFor(getBaseClass());
if(m_superCld.isAbstract() || m_superCld.isInterface())
{
throw new MetadataException("Super class mapping only work for real class, but declared super class" +
" is an interface or is abstract. Declared class: " + m_superCld.getClassNameOfObject());
}
}
m_superCldSet = true;
}
return m_superCld;
} | getSuperClassDescriptor |
public void addExtentClass(String newExtentClassName)
{
extentClassNames.add(newExtentClassName);
if(m_repository != null) m_repository.addExtent(newExtentClassName, this);
} | addExtentClass |
public void setProxyClass(Class newProxyClass)
{
proxyClass = newProxyClass;
if (proxyClass == null)
{
setProxyClassName(null);
}
else
{
proxyClassName = proxyClass.getName();
}
} | setProxyClass |
public FieldDescriptor getAutoIncrementField()
{
if (m_autoIncrementField == null)
{
FieldDescriptor[] fds = getPkFields();
for (int i = 0; i < fds.length; i++)
{
FieldDescriptor fd = fds[i];
if (fd.isAutoIncrement())
{
m_autoIncrementField = fd;
break;
}
}
}
if (m_autoIncrementField == null)
{
LoggerFactory.getDefaultLogger().warn(
this.getClass().getName()
+ ": "
+ "Could not find autoincrement attribute for class: "
+ this.getClassNameOfObject());
}
return m_autoIncrementField;
} | getAutoIncrementField |
public ValueContainer[] getCurrentLockingValues(Object o) throws PersistenceBrokerException
{
FieldDescriptor[] fields = getLockingFields();
ValueContainer[] result = new ValueContainer[fields.length];
for (int i = 0; i < result.length; i++)
{
result[i] = new ValueContainer(fields[i].getPersistentField().get(o), fields[i].getJdbcType());
}
return result;
} | getCurrentLockingValues |
public void updateLockingValues(Object obj) throws PersistenceBrokerException
{
FieldDescriptor[] fields = getLockingFields();
for (int i = 0; i < fields.length; i++)
{
FieldDescriptor fmd = fields[i];
if (fmd.isUpdateLock())
{
PersistentField f = fmd.getPersistentField();
Object cv = f.get(obj);
// int
if ((f.getType() == int.class) || (f.getType() == Integer.class))
{
int newCv = 0;
if (cv != null)
{
newCv = ((Number) cv).intValue();
}
newCv++;
f.set(obj, new Integer(newCv));
}
// long
else if ((f.getType() == long.class) || (f.getType() == Long.class))
{
long newCv = 0;
if (cv != null)
{
newCv = ((Number) cv).longValue();
}
newCv++;
f.set(obj, new Long(newCv));
}
// Timestamp
else if (f.getType() == Timestamp.class)
{
long newCv = System.currentTimeMillis();
f.set(obj, new Timestamp(newCv));
}
}
}
} | updateLockingValues |
public Constructor getZeroArgumentConstructor()
{
if (zeroArgumentConstructor == null && !alreadyLookedupZeroArguments)
{
try
{
zeroArgumentConstructor = getClassOfObject().getConstructor(NO_PARAMS);
}
catch (NoSuchMethodException e)
{
//no public zero argument constructor available let's try for a private/protected one
try
{
zeroArgumentConstructor = getClassOfObject().getDeclaredConstructor(NO_PARAMS);
//we found one, now let's make it accessible
zeroArgumentConstructor.setAccessible(true);
}
catch (NoSuchMethodException e2)
{
//out of options, log the fact and let the method return null
LoggerFactory.getDefaultLogger().warn(
this.getClass().getName()
+ ": "
+ "No zero argument constructor defined for "
+ this.getClassOfObject());
}
}
alreadyLookedupZeroArguments = true;
}
return zeroArgumentConstructor;
} | getZeroArgumentConstructor |
private synchronized void setInitializationMethod(Method newMethod)
{
if (newMethod != null)
{
// make sure it's a no argument method
if (newMethod.getParameterTypes().length > 0)
{
throw new MetadataException(
"Initialization methods must be zero argument methods: "
+ newMethod.getClass().getName()
+ "."
+ newMethod.getName());
}
// make it accessible if it's not already
if (!newMethod.isAccessible())
{
newMethod.setAccessible(true);
}
}
this.initializationMethod = newMethod;
} | setInitializationMethod |
private synchronized void setFactoryMethod(Method newMethod)
{
if (newMethod != null)
{
// make sure it's a no argument method
if (newMethod.getParameterTypes().length > 0)
{
throw new MetadataException(
"Factory methods must be zero argument methods: "
+ newMethod.getClass().getName()
+ "."
+ newMethod.getName());
}
// make it accessible if it's not already
if (!newMethod.isAccessible())
{
newMethod.setAccessible(true);
}
}
this.factoryMethod = newMethod;
} | setFactoryMethod |
protected org.apache.log4j.helpers.PatternParser createPatternParser(final String pattern) {
return new FoundationLoggingPatternParser(pattern);
} | createPatternParser |
public String format(final LoggingEvent event) {
final StringBuffer buf = new StringBuffer();
for (PatternConverter c = head; c != null; c = c.next) {
c.format(buf, event);
}
return buf.toString();
} | format |
protected String getUniqueString(FieldDescriptor field) throws SequenceManagerException
{
ResultSetAndStatement rsStmt = null;
String returnValue = null;
try
{
rsStmt = getBrokerForClass().serviceJdbcAccess().executeSQL(
"select newid()", field.getClassDescriptor(), Query.NOT_SCROLLABLE);
if (rsStmt.m_rs.next())
{
returnValue = rsStmt.m_rs.getString(1);
}
else
{
LoggerFactory.getDefaultLogger().error(this.getClass()
+ ": Can't lookup new oid for field " + field);
}
}
catch (PersistenceBrokerException e)
{
throw new SequenceManagerException(e);
}
catch (SQLException e)
{
throw new SequenceManagerException(e);
}
finally
{
// close the used resources
if (rsStmt != null) rsStmt.close();
}
return returnValue;
} | getUniqueString |
public static Object getObjectFromColumn(ResultSet rs, Integer jdbcType, int columnId)
throws SQLException
{
return getObjectFromColumn(rs, null, jdbcType, null, columnId);
} | getObjectFromColumn |
public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, java.io.IOException
{
if (flavor.isMimeTypeEqual(OJBMETADATA_FLAVOR))
return selectedDescriptors;
else
throw new UnsupportedFlavorException(flavor);
} | getTransferData |
protected void load()
{
// properties file may be set as a System property.
// if no property is set take default name.
String fn = System.getProperty(OJB_PROPERTIES_FILE, OJB_PROPERTIES_FILE);
setFilename(fn);
super.load();
// default repository & connection descriptor file
repositoryFilename = getString("repositoryFile", OJB_METADATA_FILE);
// object cache class
objectCacheClass = getClass("ObjectCacheClass", ObjectCacheDefaultImpl.class, ObjectCache.class);
// load PersistentField Class
persistentFieldClass =
getClass("PersistentFieldClass", PersistentFieldDirectImpl.class, PersistentField.class);
// load PersistenceBroker Class
persistenceBrokerClass =
getClass("PersistenceBrokerClass", PersistenceBrokerImpl.class, PersistenceBroker.class);
// load ListProxy Class
listProxyClass = getClass("ListProxyClass", ListProxyDefaultImpl.class);
// load SetProxy Class
setProxyClass = getClass("SetProxyClass", SetProxyDefaultImpl.class);
// load CollectionProxy Class
collectionProxyClass = getClass("CollectionProxyClass", CollectionProxyDefaultImpl.class);
// load IndirectionHandler Class
indirectionHandlerClass =
getClass("IndirectionHandlerClass", IndirectionHandlerJDKImpl.class, IndirectionHandler.class);
// load ProxyFactory Class
proxyFactoryClass =
getClass("ProxyFactoryClass", ProxyFactoryJDKImpl.class, ProxyFactory.class);
// load configuration for ImplicitLocking parameter:
useImplicitLocking = getBoolean("ImplicitLocking", false);
// load configuration for LockAssociations parameter:
lockAssociationAsWrites = (getString("LockAssociations", "WRITE").equalsIgnoreCase("WRITE"));
// load OQL Collection Class
oqlCollectionClass = getClass("OqlCollectionClass", DListImpl.class, ManageableCollection.class);
// set the limit for IN-sql , -1 for no limits
sqlInLimit = getInteger("SqlInLimit", -1);
//load configuration for PB pool
maxActive = getInteger(PoolConfiguration.MAX_ACTIVE,
PoolConfiguration.DEFAULT_MAX_ACTIVE);
maxIdle = getInteger(PoolConfiguration.MAX_IDLE,
PoolConfiguration.DEFAULT_MAX_IDLE);
maxWait = getLong(PoolConfiguration.MAX_WAIT,
PoolConfiguration.DEFAULT_MAX_WAIT);
timeBetweenEvictionRunsMillis = getLong(PoolConfiguration.TIME_BETWEEN_EVICTION_RUNS_MILLIS,
PoolConfiguration.DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS);
minEvictableIdleTimeMillis = getLong(PoolConfiguration.MIN_EVICTABLE_IDLE_TIME_MILLIS,
PoolConfiguration.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS);
whenExhaustedAction = getByte(PoolConfiguration.WHEN_EXHAUSTED_ACTION,
PoolConfiguration.DEFAULT_WHEN_EXHAUSTED_ACTION);
useSerializedRepository = getBoolean("useSerializedRepository", false);
} | load |
public Collection getReaders(Object obj)
{
Collection result = null;
try
{
Identity oid = new Identity(obj, getBroker());
byte selector = (byte) 'r';
byte[] requestBarr = buildRequestArray(oid, selector);
HttpURLConnection conn = getHttpUrlConnection();
//post request
BufferedOutputStream out = new BufferedOutputStream(conn.getOutputStream());
out.write(requestBarr,0,requestBarr.length);
out.flush();
// read result from
InputStream in = conn.getInputStream();
ObjectInputStream ois = new ObjectInputStream(in);
result = (Collection) ois.readObject();
// cleanup
ois.close();
out.close();
conn.disconnect();
}
catch (Throwable t)
{
throw new PersistenceBrokerException(t);
}
return result;
} | getReaders |
public void addColumnPair(String localColumn, String remoteColumn)
{
if (!_localColumns.contains(localColumn))
{
_localColumns.add(localColumn);
}
if (!_remoteColumns.contains(remoteColumn))
{
_remoteColumns.add(remoteColumn);
}
} | addColumnPair |
public int compare(Object objA, Object objB)
{
String idAStr = _table.getColumn((String)objA).getProperty("id");
String idBStr = _table.getColumn((String)objB).getProperty("id");
int idA;
int idB;
try {
idA = Integer.parseInt(idAStr);
}
catch (Exception ex) {
return 1;
}
try {
idB = Integer.parseInt(idBStr);
}
catch (Exception ex) {
return -1;
}
return idA < idB ? -1 : (idA > idB ? 1 : 0);
} | compare |
public String getAlias(String path)
{
if (m_allPathsAliased && m_attributePath.lastIndexOf(path) != -1)
{
return m_name;
}
Object retObj = m_mapping.get(path);
if (retObj != null)
{
return (String) retObj;
}
return null;
} | getAlias |
public void addClass(ClassDescriptorDef classDef)
{
classDef.setOwner(this);
// Regardless of the format of the class name, we're using the fully qualified format
// This is safe because of the package & class naming constraints of the Java language
_classDefs.put(classDef.getQualifiedName(), classDef);
} | addClass |
public void checkConstraints(String checkLevel) throws ConstraintException
{
// check constraints now after all classes have been processed
for (Iterator it = getClasses(); it.hasNext();)
{
((ClassDescriptorDef)it.next()).checkConstraints(checkLevel);
}
// additional model constraints that either deal with bigger parts of the model or
// can only be checked after the individual classes have been checked (e.g. specific
// attributes have been ensured)
new ModelConstraints().check(this, checkLevel);
} | checkConstraints |
public FinishRequest toFinishRequest(boolean includeHeaders) {
if (includeHeaders) {
return new FinishRequest(body, copyHeaders(headers), statusCode);
} else {
String mime = null;
if (body!=null) {
mime = "text/plain";
if (headers!=null && (headers.containsKey("Content-Type") || headers.containsKey("content-type"))) {
mime = headers.get("Content-Type");
if (mime==null) {
mime = headers.get("content-type");
}
}
}
return new FinishRequest(body, mime, statusCode);
}
} | toFinishRequest |
public void setAttributeEditable(Attribute attribute, boolean editable) {
attribute.setEditable(editable);
if (!(attribute instanceof LazyAttribute)) { // should not instantiate lazy attributes!
if (attribute instanceof ManyToOneAttribute) {
setAttributeEditable(((ManyToOneAttribute) attribute).getValue(), editable);
} else if (attribute instanceof OneToManyAttribute) {
List<AssociationValue> values = ((OneToManyAttribute) attribute).getValue();
for (AssociationValue value : values) {
setAttributeEditable(value, editable);
}
}
}
} | setAttributeEditable |
private void increaseBeliefCount(String bName) {
Object belief = this.getBelief(bName);
int count = 0;
if (belief!=null) {
count = (Integer) belief;
}
this.setBelief(bName, count + 1);
} | increaseBeliefCount |
private void setBelief(String bName, Object value) {
introspector.setBeliefValue(this.getLocalName(), bName, value, null);
} | setBelief |
public static Organization createOrganization(final String name){
final Organization organization = new Organization();
organization.setName(name);
return organization;
} | createOrganization |
public static Module createModule(final String name,final String version){
final Module module = new Module();
module.setName(name);
module.setVersion(version);
module.setPromoted(false);
return module;
} | createModule |
public static Artifact createArtifact(final String groupId, final String artifactId, final String version, final String classifier, final String type, final String extension, final String origin){
final Artifact artifact = new Artifact();
artifact.setGroupId(groupId);
artifact.setArtifactId(artifactId);
artifact.setVersion(version);
if(classifier != null){
artifact.setClassifier(classifier);
}
if(type != null){
artifact.setType(type);
}
if(extension != null){
artifact.setExtension(extension);
}
artifact.setOrigin(origin == null ? "maven" : origin);
return artifact;
} | createArtifact |
public static License createLicense(final String name, final String longName, final String comments, final String regexp, final String url){
final License license = new License();
license.setName(name);
license.setLongName(longName);
license.setComments(comments);
license.setRegexp(regexp);
license.setUrl(url);
return license;
} | createLicense |
public static Comment createComment(final String entityId,
final String entityType,
final String action,
final String commentedText,
final String user,
final Date date) {
final Comment comment = new Comment();
comment.setEntityId(entityId);
comment.setEntityType(entityType);
comment.setAction(action);
comment.setCommentText(commentedText);
comment.setCommentedBy(user);
comment.setCreatedDateTime(date);
return comment;
} | createComment |
private void writeAllEnvelopes(boolean reuse)
{
// perform remove of m:n indirection table entries first
performM2NUnlinkEntries();
Iterator iter;
// using clone to avoid ConcurentModificationException
iter = ((List) mvOrderOfIds.clone()).iterator();
while(iter.hasNext())
{
ObjectEnvelope mod = (ObjectEnvelope) mhtObjectEnvelopes.get(iter.next());
boolean insert = false;
if(needsCommit)
{
insert = mod.needsInsert();
mod.getModificationState().commit(mod);
if(reuse && insert)
{
getTransaction().doSingleLock(mod.getClassDescriptor(), mod.getObject(), mod.getIdentity(), Transaction.WRITE);
}
}
/*
arminw: important to call this cleanup method for each registered
ObjectEnvelope, because this method will e.g. remove proxy listener
objects for registered objects.
*/
mod.cleanup(reuse, insert);
}
// add m:n indirection table entries
performM2NLinkEntries();
} | writeAllEnvelopes |
private void checkAllEnvelopes(PersistenceBroker broker)
{
Iterator iter = ((List) mvOrderOfIds.clone()).iterator();
while(iter.hasNext())
{
ObjectEnvelope mod = (ObjectEnvelope) mhtObjectEnvelopes.get(iter.next());
// only non transient objects should be performed
if(!mod.getModificationState().isTransient())
{
mod.markReferenceElements(broker);
}
}
} | checkAllEnvelopes |
public void rollback()
{
try
{
Iterator iter = mvOrderOfIds.iterator();
while(iter.hasNext())
{
ObjectEnvelope mod = (ObjectEnvelope) mhtObjectEnvelopes.get(iter.next());
if(log.isDebugEnabled())
log.debug("rollback: " + mod);
// if the Object has been modified by transaction, mark object as dirty
if(mod.hasChanged(transaction.getBroker()))
{
mod.setModificationState(mod.getModificationState().markDirty());
}
mod.getModificationState().rollback(mod);
}
}
finally
{
needsCommit = false;
}
afterWriteCleanup();
} | rollback |
public void remove(Object pKey)
{
Identity id;
if(pKey instanceof Identity)
{
id = (Identity) pKey;
}
else
{
id = transaction.getBroker().serviceIdentity().buildIdentity(pKey);
}
mhtObjectEnvelopes.remove(id);
mvOrderOfIds.remove(id);
} | remove |
private void reorder()
{
if(getTransaction().isOrdering() && needsCommit && mhtObjectEnvelopes.size() > 1)
{
ObjectEnvelopeOrdering ordering = new ObjectEnvelopeOrdering(mvOrderOfIds, mhtObjectEnvelopes);
ordering.reorder();
Identity[] newOrder = ordering.getOrdering();
mvOrderOfIds.clear();
for(int i = 0; i < newOrder.length; i++)
{
mvOrderOfIds.add(newOrder[i]);
}
}
} | reorder |
private void cascadeMarkedForInsert()
{
// This list was used to avoid endless recursion on circular references
List alreadyPrepared = new ArrayList();
for(int i = 0; i < markedForInsertList.size(); i++)
{
ObjectEnvelope mod = (ObjectEnvelope) markedForInsertList.get(i);
// only if a new object was found we cascade to register the dependent objects
if(mod.needsInsert())
{
cascadeInsertFor(mod, alreadyPrepared);
alreadyPrepared.clear();
}
}
markedForInsertList.clear();
} | cascadeMarkedForInsert |
private void cascadeInsertFor(ObjectEnvelope mod, List alreadyPrepared)
{
// avoid endless recursion, so use List for registration
if(alreadyPrepared.contains(mod.getIdentity())) return;
alreadyPrepared.add(mod.getIdentity());
ClassDescriptor cld = getTransaction().getBroker().getClassDescriptor(mod.getObject().getClass());
List refs = cld.getObjectReferenceDescriptors(true);
cascadeInsertSingleReferences(mod, refs, alreadyPrepared);
List colls = cld.getCollectionDescriptors(true);
cascadeInsertCollectionReferences(mod, colls, alreadyPrepared);
} | cascadeInsertFor |
private void cascadeMarkedForDeletion()
{
List alreadyPrepared = new ArrayList();
for(int i = 0; i < markedForDeletionList.size(); i++)
{
ObjectEnvelope mod = (ObjectEnvelope) markedForDeletionList.get(i);
// if the object wasn't associated with another object, start cascade delete
if(!isNewAssociatedObject(mod.getIdentity()))
{
cascadeDeleteFor(mod, alreadyPrepared);
alreadyPrepared.clear();
}
}
markedForDeletionList.clear();
} | cascadeMarkedForDeletion |
private void cascadeDeleteFor(ObjectEnvelope mod, List alreadyPrepared)
{
// avoid endless recursion
if(alreadyPrepared.contains(mod.getIdentity())) return;
alreadyPrepared.add(mod.getIdentity());
ClassDescriptor cld = getTransaction().getBroker().getClassDescriptor(mod.getObject().getClass());
List refs = cld.getObjectReferenceDescriptors(true);
cascadeDeleteSingleReferences(mod, refs, alreadyPrepared);
List colls = cld.getCollectionDescriptors(true);
cascadeDeleteCollectionReferences(mod, colls, alreadyPrepared);
} | cascadeDeleteFor |
public ManageableCollection getCollectionByQuery(Class collectionClass, Query query, boolean lazy) throws PersistenceBrokerException
{
ManageableCollection result;
try
{
// BRJ: return empty Collection for null query
if (query == null)
{
result = (ManageableCollection)collectionClass.newInstance();
}
else
{
if (lazy)
{
result = pb.getProxyFactory().createCollectionProxy(pb.getPBKey(), query, collectionClass);
}
else
{
result = getCollectionByQuery(collectionClass, query.getSearchClass(), query);
}
}
return result;
}
catch (Exception e)
{
if(e instanceof PersistenceBrokerException)
{
throw (PersistenceBrokerException) e;
}
else
{
throw new PersistenceBrokerException(e);
}
}
} | getCollectionByQuery |
public void retrieveReferences(Object newObj, ClassDescriptor cld, boolean forced) throws PersistenceBrokerException
{
Iterator i = cld.getObjectReferenceDescriptors().iterator();
// turn off auto prefetching for related proxies
final Class saveClassToPrefetch = classToPrefetch;
classToPrefetch = null;
pb.getInternalCache().enableMaterializationCache();
try
{
while (i.hasNext())
{
ObjectReferenceDescriptor rds = (ObjectReferenceDescriptor) i.next();
retrieveReference(newObj, cld, rds, forced);
}
pb.getInternalCache().disableMaterializationCache();
}
catch(RuntimeException e)
{
pb.getInternalCache().doLocalClear();
throw e;
}
finally
{
classToPrefetch = saveClassToPrefetch;
}
} | retrieveReferences |
private boolean hasNullifiedFK(FieldDescriptor[] fkFieldDescriptors, Object[] fkValues)
{
boolean result = true;
for (int i = 0; i < fkValues.length; i++)
{
if (!pb.serviceBrokerHelper().representsNull(fkFieldDescriptors[i], fkValues[i]))
{
result = false;
break;
}
}
return result;
} | hasNullifiedFK |
private Query getFKQuery(Object obj, ClassDescriptor cld, CollectionDescriptor cds)
{
Query fkQuery;
QueryByCriteria fkQueryCrit;
if (cds.isMtoNRelation())
{
fkQueryCrit = getFKQueryMtoN(obj, cld, cds);
}
else
{
fkQueryCrit = getFKQuery1toN(obj, cld, cds);
}
// check if collection must be ordered
if (!cds.getOrderBy().isEmpty())
{
Iterator iter = cds.getOrderBy().iterator();
while (iter.hasNext())
{
fkQueryCrit.addOrderBy((FieldHelper)iter.next());
}
}
// BRJ: customize the query
if (cds.getQueryCustomizer() != null)
{
fkQuery = cds.getQueryCustomizer().customizeQuery(obj, pb, cds, fkQueryCrit);
}
else
{
fkQuery = fkQueryCrit;
}
return fkQuery;
} | getFKQuery |
public Query getPKQuery(Identity oid)
{
Object[] values = oid.getPrimaryKeyValues();
ClassDescriptor cld = pb.getClassDescriptor(oid.getObjectsTopLevelClass());
FieldDescriptor[] fields = cld.getPkFields();
Criteria criteria = new Criteria();
for (int i = 0; i < fields.length; i++)
{
FieldDescriptor fld = fields[i];
criteria.addEqualTo(fld.getAttributeName(), values[i]);
}
return QueryFactory.newQuery(cld.getClassOfObject(), criteria);
} | getPKQuery |
public void retrieveCollections(Object newObj, ClassDescriptor cld, boolean forced) throws PersistenceBrokerException
{
doRetrieveCollections(newObj, cld, forced, false);
} | retrieveCollections |
public void retrieveProxyCollections(Object newObj, ClassDescriptor cld, boolean forced) throws PersistenceBrokerException
{
doRetrieveCollections(newObj, cld, forced, true);
} | retrieveProxyCollections |
public void removePrefetchingListeners()
{
if (prefetchingListeners != null)
{
for (Iterator it = prefetchingListeners.iterator(); it.hasNext(); )
{
PBPrefetchingListener listener = (PBPrefetchingListener) it.next();
listener.removeThisListener();
}
prefetchingListeners.clear();
}
} | removePrefetchingListeners |
@PostConstruct
protected void init() throws IOException {
// base configuration from XML file
if (null != configurationFile) {
log.debug("Get base configuration from {}", configurationFile);
manager = new DefaultCacheManager(configurationFile);
} else {
GlobalConfigurationBuilder builder = new GlobalConfigurationBuilder();
builder.globalJmxStatistics().allowDuplicateDomains(true);
manager = new DefaultCacheManager(builder.build());
}
if (listener == null) {
listener = new InfinispanCacheListener();
}
manager.addListener(listener);
// cache for caching the cache configurations (hmmm, sounds a bit strange)
Map<String, Map<CacheCategory, CacheService>> cacheCache =
new HashMap<String, Map<CacheCategory, CacheService>>();
// build default configuration
if (null != defaultConfiguration) {
setCaches(cacheCache, null, defaultConfiguration);
}
// build layer specific configurations
for (Layer layer : layerMap.values()) {
CacheInfo ci = configurationService.getLayerExtraInfo(layer.getLayerInfo(), CacheInfo.class);
if (null != ci) {
setCaches(cacheCache, layer, ci);
}
}
} | init |
protected static String ConvertBinaryOperator(int oper)
{
// Convert the operator into the proper string
String oper_string;
switch (oper)
{
default:
case EQUAL:
oper_string = "=";
break;
case LIKE:
oper_string = "LIKE";
break;
case NOT_EQUAL:
oper_string = "!=";
break;
case LESS_THAN:
oper_string = "<";
break;
case GREATER_THAN:
oper_string = ">";
break;
case GREATER_EQUAL:
oper_string = ">=";
break;
case LESS_EQUAL:
oper_string = "<=";
break;
}
return oper_string;
} | ConvertBinaryOperator |
public void writeObject(Object o, GraphicsDocument document, boolean asChild) throws RenderException {
document.writeElement("vml:shape", asChild);
Point p = (Point) o;
String adj = document.getFormatter().format(p.getX()) + ","
+ document.getFormatter().format(p.getY());
document.writeAttribute("adj", adj);
} | writeObject |
public void setStatusBarMessage(final String message)
{
// Guaranteed to return a non-null array
Object[] listeners = listenerList.getListenerList();
// Process the listeners last to first, notifying
// those that are interested in this event
for (int i = listeners.length-2; i>=0; i-=2) {
if (listeners[i]==StatusMessageListener.class)
{
((StatusMessageListener)listeners[i+1]).statusMessageReceived(message);
}
}
} | setStatusBarMessage |
public void reportSqlError(String message, java.sql.SQLException sqlEx)
{
StringBuffer strBufMessages = new StringBuffer();
java.sql.SQLException currentSqlEx = sqlEx;
do
{
strBufMessages.append("\n" + sqlEx.getErrorCode() + ":" + sqlEx.getMessage());
currentSqlEx = currentSqlEx.getNextException();
} while (currentSqlEx != null);
System.err.println(message + strBufMessages.toString());
sqlEx.printStackTrace();
} | reportSqlError |
public Object copy(final Object obj, final PersistenceBroker broker)
{
return clone(obj, IdentityMapFactory.getIdentityMap(), broker);
} | copy |
protected Object getObjectFromResultSet() throws PersistenceBrokerException
{
try
{
// if all primitive attributes of the object are contained in the ResultSet
// the fast direct mapping can be used
return super.getObjectFromResultSet();
}
// if the full loading failed we assume that at least PK attributes are contained
// in the ResultSet and perform a slower Identity based loading...
// This may of course also fail and can throw another PersistenceBrokerException
catch (PersistenceBrokerException e)
{
Identity oid = getIdentityFromResultSet();
return getBroker().getObjectByIdentity(oid);
}
} | getObjectFromResultSet |
public void createInsertionSql(Database model, Platform platform, Writer writer) throws IOException
{
for (Iterator it = _beans.iterator(); it.hasNext();)
{
writer.write(platform.getInsertSql(model, (DynaBean)it.next()));
if (it.hasNext())
{
writer.write("\n");
}
}
} | createInsertionSql |
public void insert(Platform platform, Database model, int batchSize) throws SQLException
{
if (batchSize <= 1)
{
for (Iterator it = _beans.iterator(); it.hasNext();)
{
platform.insert(model, (DynaBean)it.next());
}
}
else
{
for (int startIdx = 0; startIdx < _beans.size(); startIdx += batchSize)
{
platform.insert(model, _beans.subList(startIdx, startIdx + batchSize));
}
}
} | insert |
private InputStream connect(String url) throws IOException {
URLConnection conn = new URL(URL_BASE + url).openConnection();
conn.setConnectTimeout(CONNECT_TIMEOUT);
conn.setReadTimeout(READ_TIMEOUT);
conn.setRequestProperty("User-Agent", USER_AGENT);
return conn.getInputStream();
} | connect |
public synchronized void abortTransaction() throws TransactionNotInProgressException
{
if(isInTransaction())
{
fireBrokerEvent(BEFORE_ROLLBACK_EVENT);
setInTransaction(false);
clearRegistrationLists();
referencesBroker.removePrefetchingListeners();
/*
arminw:
check if we in local tx, before do local rollback
Necessary, because ConnectionManager may do a rollback by itself
or in managed environments the used connection is already be closed
*/
if(connectionManager.isInLocalTransaction()) this.connectionManager.localRollback();
fireBrokerEvent(AFTER_ROLLBACK_EVENT);
}
} | abortTransaction |
public void delete(Object obj, boolean ignoreReferences) throws PersistenceBrokerException
{
if(isTxCheck() && !isInTransaction())
{
if(logger.isEnabledFor(Logger.ERROR))
{
String msg = "No running PB-tx found. Please, only delete objects in context of a PB-transaction" +
" to avoid side-effects - e.g. when rollback of complex objects.";
try
{
throw new Exception("** Delete object without active PersistenceBroker transaction **");
}
catch(Exception e)
{
logger.error(msg, e);
}
}
}
try
{
doDelete(obj, ignoreReferences);
}
finally
{
markedForDelete.clear();
}
} | delete |
private void doDelete(Object obj, boolean ignoreReferences) throws PersistenceBrokerException
{
//logger.info("DELETING " + obj);
// object is not null
if (obj != null)
{
obj = getProxyFactory().getRealObject(obj);
/**
* Kuali Foundation modification -- 8/24/2007
*/
if ( obj == null ) return;
/**
* End of Kuali Foundation modification
*/
/**
* MBAIRD
* 1. if we are marked for delete already, avoid recursing on this object
*
* arminw:
* use object instead Identity object in markedForDelete List,
* because using objects we get a better performance. I can't find
* side-effects in doing so.
*/
if (markedForDelete.contains(obj))
{
return;
}
ClassDescriptor cld = getClassDescriptor(obj.getClass());
//BRJ: check for valid pk
if (!serviceBrokerHelper().assertValidPkForDelete(cld, obj))
{
String msg = "Cannot delete object without valid PKs. " + obj;
logger.error(msg);
return;
}
/**
* MBAIRD
* 2. register object in markedForDelete map.
*/
markedForDelete.add(obj);
Identity oid = serviceIdentity().buildIdentity(cld, obj);
// Invoke events on PersistenceBrokerAware instances and listeners
BEFORE_DELETE_EVENT.setTarget(obj);
fireBrokerEvent(BEFORE_DELETE_EVENT);
BEFORE_DELETE_EVENT.setTarget(null);
// now perform deletion
performDeletion(cld, obj, oid, ignoreReferences);
// Invoke events on PersistenceBrokerAware instances and listeners
AFTER_DELETE_EVENT.setTarget(obj);
fireBrokerEvent(AFTER_DELETE_EVENT);
AFTER_DELETE_EVENT.setTarget(null);
// let the connection manager to execute batch
connectionManager.executeBatchIfNecessary();
}
} | doDelete |
private void deleteByQuery(Query query, ClassDescriptor cld) throws PersistenceBrokerException
{
if (logger.isDebugEnabled())
{
logger.debug("deleteByQuery " + cld.getClassNameOfObject() + ", " + query);
}
if (query instanceof QueryBySQL)
{
String sql = ((QueryBySQL) query).getSql();
this.dbAccess.executeUpdateSQL(sql, cld);
}
else
{
// if query is Identity based transform it to a criteria based query first
if (query instanceof QueryByIdentity)
{
QueryByIdentity qbi = (QueryByIdentity) query;
Object oid = qbi.getExampleObject();
// make sure it's an Identity
if (!(oid instanceof Identity))
{
oid = serviceIdentity().buildIdentity(oid);
}
query = referencesBroker.getPKQuery((Identity) oid);
}
if (!cld.isInterface())
{
this.dbAccess.executeDelete(query, cld);
}
// if class is an extent, we have to delete all extent classes too
String lastUsedTable = cld.getFullTableName();
if (cld.isExtent())
{
Iterator extents = getDescriptorRepository().getAllConcreteSubclassDescriptors(cld).iterator();
while (extents.hasNext())
{
ClassDescriptor extCld = (ClassDescriptor) extents.next();
// read same table only once
if (!extCld.getFullTableName().equals(lastUsedTable))
{
lastUsedTable = extCld.getFullTableName();
this.dbAccess.executeDelete(query, extCld);
}
}
}
}
} | deleteByQuery |
public void store(Object obj) throws PersistenceBrokerException
{
obj = extractObjectToStore(obj);
// only do something if obj != null
if(obj == null) return;
ClassDescriptor cld = getClassDescriptor(obj.getClass());
/*
if one of the PK fields was null, we assume the objects
was new and needs insert
*/
boolean insert = serviceBrokerHelper().hasNullPKField(cld, obj);
Identity oid = serviceIdentity().buildIdentity(cld, obj);
/*
if PK values are set, lookup cache or db to see whether object
needs insert or update
*/
if (!insert)
{
insert = objectCache.lookup(oid) == null
&& !serviceBrokerHelper().doesExist(cld, oid, obj);
}
store(obj, oid, cld, insert);
} | store |
protected void store(Object obj, Identity oid, ClassDescriptor cld, boolean insert)
{
store(obj, oid, cld, insert, false);
} | store |
public void link(Object targetObject, ClassDescriptor cld, ObjectReferenceDescriptor rds, Object referencedObject, boolean insert)
{
// MBAIRD: we have 'disassociated' this object from the referenced object,
// the object represented by the reference descriptor is now null, so set
// the fk in the target object to null.
// arminw: if an insert was done and ref object was null, we should allow
// to pass FK fields of main object (maybe only the FK fields are set)
if (referencedObject == null)
{
/*
arminw:
if update we set FK fields to 'null', because reference was disassociated
We do nothing on insert, maybe only the FK fields of main object (without
materialization of the reference object) are set by the user
*/
if(!insert)
{
unlinkFK(targetObject, cld, rds);
}
}
else
{
setFKField(targetObject, cld, rds, referencedObject);
}
} | link |
public void unlinkFK(Object targetObject, ClassDescriptor cld, ObjectReferenceDescriptor rds)
{
setFKField(targetObject, cld, rds, null);
} | unlinkFK |
public void linkOneToOne(Object obj, ClassDescriptor cld, ObjectReferenceDescriptor rds, boolean insert)
{
storeAndLinkOneToOne(true, obj, cld, rds, true);
} | linkOneToOne |
public void linkOneToMany(Object obj, CollectionDescriptor cod, boolean insert)
{
Object referencedObjects = cod.getPersistentField().get(obj);
storeAndLinkOneToMany(true, obj, cod,referencedObjects, insert);
} | linkOneToMany |
public void linkMtoN(Object obj, CollectionDescriptor cod, boolean insert)
{
Object referencedObjects = cod.getPersistentField().get(obj);
storeAndLinkMtoN(true, obj, cod, referencedObjects, insert);
} | linkMtoN |
public void retrieveReference(Object pInstance, String pAttributeName) throws PersistenceBrokerException
{
if (logger.isDebugEnabled())
{
logger.debug("Retrieving reference named ["+pAttributeName+"] on object of type ["+
pInstance.getClass().getName()+"]");
}
ClassDescriptor cld = getClassDescriptor(pInstance.getClass());
CollectionDescriptor cod = cld.getCollectionDescriptorByName(pAttributeName);
getInternalCache().enableMaterializationCache();
// to avoid problems with circular references, locally cache the current object instance
Identity oid = serviceIdentity().buildIdentity(pInstance);
boolean needLocalRemove = false;
if(getInternalCache().doLocalLookup(oid) == null)
{
getInternalCache().doInternalCache(oid, pInstance, MaterializationCache.TYPE_TEMP);
needLocalRemove = true;
}
try
{
if (cod != null)
{
referencesBroker.retrieveCollection(pInstance, cld, cod, true);
}
else
{
ObjectReferenceDescriptor ord = cld.getObjectReferenceDescriptorByName(pAttributeName);
if (ord != null)
{
referencesBroker.retrieveReference(pInstance, cld, ord, true);
}
else
{
throw new PersistenceBrokerException("did not find attribute " + pAttributeName +
" for class " + pInstance.getClass().getName());
}
}
// do locally remove the object to avoid problems with object state detection (insert/update),
// because objects found in the cache detected as 'old' means 'update'
if(needLocalRemove) getInternalCache().doLocalRemove(oid);
getInternalCache().disableMaterializationCache();
}
catch(RuntimeException e)
{
getInternalCache().doLocalClear();
throw e;
}
} | retrieveReference |
public ManageableCollection getCollectionByQuery(Class collectionClass, Query query)
throws PersistenceBrokerException
{
return referencesBroker.getCollectionByQuery(collectionClass, query, false);
} | getCollectionByQuery |
protected OJBIterator getIteratorFromQuery(Query query, ClassDescriptor cld) throws PersistenceBrokerException
{
RsIteratorFactory factory = RsIteratorFactoryImpl.getInstance();
OJBIterator result = getRsIteratorFromQuery(query, cld, factory);
if (query.usePaging())
{
result = new PagingIterator(result, query.getStartAtIndex(), query.getEndAtIndex());
}
return result;
} | getIteratorFromQuery |
public Object doGetObjectByIdentity(Identity id) throws PersistenceBrokerException
{
if (logger.isDebugEnabled()) logger.debug("getObjectByIdentity " + id);
// check if object is present in ObjectCache:
Object obj = objectCache.lookup(id);
// only perform a db lookup if necessary (object not cached yet)
if (obj == null)
{
obj = getDBObject(id);
}
else
{
ClassDescriptor cld = getClassDescriptor(obj.getClass());
// if specified in the ClassDescriptor the instance must be refreshed
if (cld.isAlwaysRefresh())
{
refreshInstance(obj, id, cld);
}
// now refresh all references
checkRefreshRelationships(obj, id, cld);
}
// Invoke events on PersistenceBrokerAware instances and listeners
AFTER_LOOKUP_EVENT.setTarget(obj);
fireBrokerEvent(AFTER_LOOKUP_EVENT);
AFTER_LOOKUP_EVENT.setTarget(null);
//logger.info("RETRIEVING object " + obj);
return obj;
} | doGetObjectByIdentity |
private void refreshInstance(Object cachedInstance, Identity oid, ClassDescriptor cld)
{
// read in fresh copy from the db, but do not cache it
Object freshInstance = getPlainDBObject(cld, oid);
// update all primitive typed attributes
FieldDescriptor[] fields = cld.getFieldDescriptions();
FieldDescriptor fmd;
PersistentField fld;
for (int i = 0; i < fields.length; i++)
{
fmd = fields[i];
fld = fmd.getPersistentField();
fld.set(cachedInstance, fld.get(freshInstance));
}
} | refreshInstance |
public Object getObjectByQuery(Query query) throws PersistenceBrokerException
{
Object result = null;
if (query instanceof QueryByIdentity)
{
// example obj may be an entity or an Identity
Object obj = query.getExampleObject();
if (obj instanceof Identity)
{
Identity oid = (Identity) obj;
result = getObjectByIdentity(oid);
}
else
{
// TODO: This workaround doesn't allow 'null' for PK fields
if (!serviceBrokerHelper().hasNullPKField(getClassDescriptor(obj.getClass()), obj))
{
Identity oid = serviceIdentity().buildIdentity(obj);
result = getObjectByIdentity(oid);
}
}
}
else
{
Class itemClass = query.getSearchClass();
ClassDescriptor cld = getClassDescriptor(itemClass);
/*
use OJB intern Iterator, thus we are able to close used
resources instantly
*/
OJBIterator it = getIteratorFromQuery(query, cld);
/*
arminw:
patch by Andre Clute, instead of taking the first found result
try to get the first found none null result.
He wrote:
I have a situation where an item with a certain criteria is in my
database twice -- once deleted, and then a non-deleted version of it.
When I do a PB.getObjectByQuery(), the RsIterator get's both results
from the database, but the first row is the deleted row, so my RowReader
filters it out, and do not get the right result.
*/
try
{
while (result==null && it.hasNext())
{
result = it.next();
}
} // make sure that we close the used resources
finally
{
if(it != null) it.releaseDbResources();
}
}
return result;
} | getObjectByQuery |
public Enumeration getPKEnumerationByQuery(Class primaryKeyClass, Query query) throws PersistenceBrokerException
{
if (logger.isDebugEnabled()) logger.debug("getPKEnumerationByQuery " + query);
query.setFetchSize(1);
ClassDescriptor cld = getClassDescriptor(query.getSearchClass());
return new PkEnumeration(query, cld, primaryKeyClass, this);
} | getPKEnumerationByQuery |
public void store(Object obj, ObjectModification mod) throws PersistenceBrokerException
{
obj = extractObjectToStore(obj);
// null for unmaterialized Proxy
if (obj == null)
{
return;
}
ClassDescriptor cld = getClassDescriptor(obj.getClass());
// this call ensures that all autoincremented primary key attributes are filled
Identity oid = serviceIdentity().buildIdentity(cld, obj);
// select flag for insert / update selection by checking the ObjectModification
if (mod.needsInsert())
{
store(obj, oid, cld, true);
}
else if (mod.needsUpdate())
{
store(obj, oid, cld, false);
}
/*
arminw
TODO: Why we need this behaviour? What about 1:1 relations?
*/
else
{
// just store 1:n and m:n associations
storeCollections(obj, cld, mod.needsInsert());
}
} | store |
private void storeToDb(Object obj, ClassDescriptor cld, Identity oid, boolean insert, boolean ignoreReferences)
{
// 1. link and store 1:1 references
storeReferences(obj, cld, insert, ignoreReferences);
Object[] pkValues = oid.getPrimaryKeyValues();
if (!serviceBrokerHelper().assertValidPksForStore(cld.getPkFields(), pkValues))
{
// BRJ: fk values may be part of pk, but the are not known during
// creation of Identity. so we have to get them here
pkValues = serviceBrokerHelper().getKeyValues(cld, obj);
if (!serviceBrokerHelper().assertValidPksForStore(cld.getPkFields(), pkValues))
{
String append = insert ? " on insert" : " on update" ;
throw new PersistenceBrokerException("assertValidPkFields failed for Object of type: " + cld.getClassNameOfObject() + append);
}
}
// get super class cld then store it with the object
/*
now for multiple table inheritance
1. store super classes, topmost parent first
2. go down through heirarchy until current class
3. todo: store to full extent?
// arminw: TODO: The extend-attribute feature dosn't work, should we remove this stuff?
This if-clause will go up the inheritance heirarchy to store all the super classes.
The id for the top most super class will be the id for all the subclasses too
*/
if(cld.getSuperClass() != null)
{
ClassDescriptor superCld = getDescriptorRepository().getDescriptorFor(cld.getSuperClass());
storeToDb(obj, superCld, oid, insert);
// arminw: why this?? I comment out this section
// storeCollections(obj, cld.getCollectionDescriptors(), insert);
}
// 2. store primitive typed attributes (Or is THIS step 3 ?)
// if obj not present in db use INSERT
if (insert)
{
dbAccess.executeInsert(cld, obj);
if(oid.isTransient())
{
// Create a new Identity based on the current set of primary key values.
oid = serviceIdentity().buildIdentity(cld, obj);
}
}
// else use UPDATE
else
{
try
{
dbAccess.executeUpdate(cld, obj);
}
catch(OptimisticLockException e)
{
// ensure that the outdated object be removed from cache
objectCache.remove(oid);
throw e;
}
}
// cache object for symmetry with getObjectByXXX()
// Add the object to the cache.
objectCache.doInternalCache(oid, obj, ObjectCacheInternal.TYPE_WRITE);
// 3. store 1:n and m:n associations
if(!ignoreReferences) storeCollections(obj, cld, insert);
} | storeToDb |
public Iterator getReportQueryIteratorByQuery(Query query) throws PersistenceBrokerException
{
ClassDescriptor cld = getClassDescriptor(query.getSearchClass());
return getReportQueryIteratorFromQuery(query, cld);
} | getReportQueryIteratorByQuery |
private OJBIterator getRsIteratorFromQuery(Query query, ClassDescriptor cld, RsIteratorFactory factory)
throws PersistenceBrokerException
{
query.setFetchSize(1);
if (query instanceof QueryBySQL)
{
if(logger.isDebugEnabled()) logger.debug("Creating SQL-RsIterator for class ["+cld.getClassNameOfObject()+"]");
return factory.createRsIterator((QueryBySQL) query, cld, this);
}
if (!cld.isExtent() || !query.getWithExtents())
{
// no extents just use the plain vanilla RsIterator
if(logger.isDebugEnabled()) logger.debug("Creating RsIterator for class ["+cld.getClassNameOfObject()+"]");
return factory.createRsIterator(query, cld, this);
}
if(logger.isDebugEnabled()) logger.debug("Creating ChainingIterator for class ["+cld.getClassNameOfObject()+"]");
ChainingIterator chainingIter = new ChainingIterator();
// BRJ: add base class iterator
if (!cld.isInterface())
{
if(logger.isDebugEnabled()) logger.debug("Adding RsIterator for class ["+cld.getClassNameOfObject()+"] to ChainingIterator");
chainingIter.addIterator(factory.createRsIterator(query, cld, this));
}
Iterator extents = getDescriptorRepository().getAllConcreteSubclassDescriptors(cld).iterator();
while (extents.hasNext())
{
ClassDescriptor extCld = (ClassDescriptor) extents.next();
// read same table only once
if (chainingIter.containsIteratorForTable(extCld.getFullTableName()))
{
if(logger.isDebugEnabled()) logger.debug("Skipping class ["+extCld.getClassNameOfObject()+"]");
}
else
{
if(logger.isDebugEnabled()) logger.debug("Adding RsIterator of class ["+extCld.getClassNameOfObject()+"] to ChainingIterator");
// add the iterator to the chaining iterator.
chainingIter.addIterator(factory.createRsIterator(query, extCld, this));
}
}
return chainingIter;
} | getRsIteratorFromQuery |
private OJBIterator getReportQueryIteratorFromQuery(Query query, ClassDescriptor cld) throws PersistenceBrokerException
{
RsIteratorFactory factory = ReportRsIteratorFactoryImpl.getInstance();
OJBIterator result = getRsIteratorFromQuery(query, cld, factory);
if (query.usePaging())
{
result = new PagingIterator(result, query.getStartAtIndex(), query.getEndAtIndex());
}
return result;
} | getReportQueryIteratorFromQuery |
public static String getModuleName(final String moduleId) {
final int splitter = moduleId.indexOf(':');
if(splitter == -1){
return moduleId;
}
return moduleId.substring(0, splitter);
} | getModuleName |
public static String getModuleVersion(final String moduleId) {
final int splitter = moduleId.lastIndexOf(':');
if(splitter == -1){
return moduleId;
}
return moduleId.substring(splitter+1);
} | getModuleVersion |
public static String getGroupId(final String gavc) {
final int splitter = gavc.indexOf(':');
if(splitter == -1){
return gavc;
}
return gavc.substring(0, splitter);
} | getGroupId |
public static List<DbModule> getAllSubmodules(final DbModule module) {
final List<DbModule> submodules = new ArrayList<DbModule>();
submodules.addAll(module.getSubmodules());
for(final DbModule submodule: module.getSubmodules()){
submodules.addAll(getAllSubmodules(submodule));
}
return submodules;
} | getAllSubmodules |
public void init(final MultivaluedMap<String, String> queryParameters) {
final String scopeCompileParam = queryParameters.getFirst(ServerAPI.SCOPE_COMPILE_PARAM);
if(scopeCompileParam != null){
this.scopeComp = Boolean.valueOf(scopeCompileParam);
}
final String scopeProvidedParam = queryParameters.getFirst(ServerAPI.SCOPE_PROVIDED_PARAM);
if(scopeProvidedParam != null){
this.scopePro = Boolean.valueOf(scopeProvidedParam);
}
final String scopeRuntimeParam = queryParameters.getFirst(ServerAPI.SCOPE_RUNTIME_PARAM);
if(scopeRuntimeParam != null){
this.scopeRun = Boolean.valueOf(scopeRuntimeParam);
}
final String scopeTestParam = queryParameters.getFirst(ServerAPI.SCOPE_TEST_PARAM);
if(scopeTestParam != null){
this.scopeTest = Boolean.valueOf(scopeTestParam);
}
} | init |
private PersistenceBroker obtainBroker()
{
PersistenceBroker _broker;
try
{
if (pbKey == null)
{
//throw new OJBRuntimeException("Not possible to do action, cause no tx runnning and no PBKey is set");
log.warn("No tx runnning and PBKey is null, try to use the default PB");
_broker = PersistenceBrokerFactory.defaultPersistenceBroker();
}
else
{
_broker = PersistenceBrokerFactory.createPersistenceBroker(pbKey);
}
}
catch (PBFactoryException e)
{
log.error("Could not obtain PB for PBKey " + pbKey, e);
throw new OJBRuntimeException("Unexpected micro-kernel exception", e);
}
return _broker;
} | obtainBroker |
private void addSequence(String sequenceName, HighLowSequence seq)
{
// lookup the sequence map for calling DB
String jcdAlias = getBrokerForClass()
.serviceConnectionManager().getConnectionDescriptor().getJcdAlias();
Map mapForDB = (Map) sequencesDBMap.get(jcdAlias);
if(mapForDB == null)
{
mapForDB = new HashMap();
}
mapForDB.put(sequenceName, seq);
sequencesDBMap.put(jcdAlias, mapForDB);
} | addSequence |
protected void removeSequence(String sequenceName)
{
// lookup the sequence map for calling DB
Map mapForDB = (Map) sequencesDBMap.get(getBrokerForClass()
.serviceConnectionManager().getConnectionDescriptor().getJcdAlias());
if(mapForDB != null)
{
synchronized(SequenceManagerHighLowImpl.class)
{
mapForDB.remove(sequenceName);
}
}
} | removeSequence |
public PBKey getPBKey()
{
if (pbKey == null)
{
this.pbKey = new PBKey(this.getJcdAlias(), this.getUserName(), this.getPassWord());
}
return pbKey;
} | getPBKey |
public void setJdbcLevel(String jdbcLevel)
{
if (jdbcLevel != null)
{
try
{
double intLevel = Double.parseDouble(jdbcLevel);
setJdbcLevel(intLevel);
}
catch(NumberFormatException nfe)
{
setJdbcLevel(2.0);
logger.info("Specified JDBC level was not numeric (Value=" + jdbcLevel + "), used default jdbc level of 2.0 ");
}
}
else
{
setJdbcLevel(2.0);
logger.info("Specified JDBC level was null, used default jdbc level of 2.0 ");
}
} | setJdbcLevel |
public synchronized boolean checkWrite(TransactionImpl tx, Object obj)
{
if (log.isDebugEnabled()) log.debug("LM.checkWrite(tx-" + tx.getGUID() + ", " + new Identity(obj, tx.getBroker()).toString() + ")");
LockStrategy lockStrategy = LockStrategyFactory.getStrategyFor(obj);
return lockStrategy.checkWrite(tx, obj);
} | checkWrite |
public void checkpoint(ObjectEnvelope mod)
throws org.apache.ojb.broker.PersistenceBrokerException
{
mod.doDelete();
mod.setModificationState(StateTransient.getInstance());
} | checkpoint |
public void checkpoint(ObjectEnvelope mod) throws PersistenceBrokerException
{
mod.doInsert();
mod.setModificationState(StateOldClean.getInstance());
} | checkpoint |
public List<String> getModuleVersions(final String name, final FiltersHolder filters) {
final List<String> versions = repositoryHandler.getModuleVersions(name, filters);
if (versions.isEmpty()) {
throw new WebApplicationException(Response.status(Response.Status.NOT_FOUND)
.entity("Module " + name + " does not exist.").build());
}
return versions;
} | getModuleVersions |
public DbModule getModule(final String moduleId) {
final DbModule dbModule = repositoryHandler.getModule(moduleId);
if (dbModule == null) {
throw new WebApplicationException(Response.status(Response.Status.NOT_FOUND)
.entity("Module " + moduleId + " does not exist.").build());
}
return dbModule;
} | getModule |
public void deleteModule(final String moduleId) {
final DbModule module = getModule(moduleId);
repositoryHandler.deleteModule(module.getId());
for (final String gavc : DataUtils.getAllArtifacts(module)) {
repositoryHandler.deleteArtifact(gavc);
}
} | deleteModule |
public List<DbLicense> getModuleLicenses(final String moduleId,
final LicenseMatcher licenseMatcher) {
final DbModule module = getModule(moduleId);
final List<DbLicense> licenses = new ArrayList<>();
final FiltersHolder filters = new FiltersHolder();
final ArtifactHandler artifactHandler = new ArtifactHandler(repositoryHandler, licenseMatcher);
for (final String gavc : DataUtils.getAllArtifacts(module)) {
licenses.addAll(artifactHandler.getArtifactLicenses(gavc, filters));
}
return licenses;
} | getModuleLicenses |
public void promoteModule(final String moduleId) {
final DbModule module = getModule(moduleId);
for (final String gavc : DataUtils.getAllArtifacts(module)) {
final DbArtifact artifact = repositoryHandler.getArtifact(gavc);
artifact.setPromoted(true);
repositoryHandler.store(artifact);
}
repositoryHandler.promoteModule(module);
} | promoteModule |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.