repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
sequence
docstring
stringlengths
3
16k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
105
339
partition
stringclasses
1 value
kuali/ojb-1.0.4
src/java/org/apache/ojb/otm/OTMKit.java
OTMKit.acquireConnection
public OTMConnection acquireConnection(PBKey pbKey) { TransactionFactory txFactory = getTransactionFactory(); return txFactory.acquireConnection(pbKey); }
java
public OTMConnection acquireConnection(PBKey pbKey) { TransactionFactory txFactory = getTransactionFactory(); return txFactory.acquireConnection(pbKey); }
[ "public", "OTMConnection", "acquireConnection", "(", "PBKey", "pbKey", ")", "{", "TransactionFactory", "txFactory", "=", "getTransactionFactory", "(", ")", ";", "return", "txFactory", ".", "acquireConnection", "(", "pbKey", ")", ";", "}" ]
Obtain an OTMConnection for the given persistence broker key
[ "Obtain", "an", "OTMConnection", "for", "the", "given", "persistence", "broker", "key" ]
9a544372f67ce965f662cdc71609dd03683c8f04
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/otm/OTMKit.java#L40-L44
train
gsi-upm/BeastTool
beast-tool/src/main/java/es/upm/dit/gsi/beast/platform/jadex/JadexMessenger.java
JadexMessenger.sendMessageToAgents
public void sendMessageToAgents(String[] agent_name, String msgtype, Object message_content, Connector connector) { HashMap<String, Object> hm = new HashMap<String, Object>(); hm.put("performative", msgtype); hm.put(SFipa.CONTENT, message_content); IComponentIdentifier[] ici = new IComponentIdentifier[agent_name.length]; for (int i = 0; i < agent_name.length; i++) { ici[i] = (IComponentIdentifier) connector.getAgentID(agent_name[i]); } ((IMessageService) connector.getMessageService()).deliverMessage(hm, "fipa", ici); }
java
public void sendMessageToAgents(String[] agent_name, String msgtype, Object message_content, Connector connector) { HashMap<String, Object> hm = new HashMap<String, Object>(); hm.put("performative", msgtype); hm.put(SFipa.CONTENT, message_content); IComponentIdentifier[] ici = new IComponentIdentifier[agent_name.length]; for (int i = 0; i < agent_name.length; i++) { ici[i] = (IComponentIdentifier) connector.getAgentID(agent_name[i]); } ((IMessageService) connector.getMessageService()).deliverMessage(hm, "fipa", ici); }
[ "public", "void", "sendMessageToAgents", "(", "String", "[", "]", "agent_name", ",", "String", "msgtype", ",", "Object", "message_content", ",", "Connector", "connector", ")", "{", "HashMap", "<", "String", ",", "Object", ">", "hm", "=", "new", "HashMap", "<", "String", ",", "Object", ">", "(", ")", ";", "hm", ".", "put", "(", "\"performative\"", ",", "msgtype", ")", ";", "hm", ".", "put", "(", "SFipa", ".", "CONTENT", ",", "message_content", ")", ";", "IComponentIdentifier", "[", "]", "ici", "=", "new", "IComponentIdentifier", "[", "agent_name", ".", "length", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "agent_name", ".", "length", ";", "i", "++", ")", "{", "ici", "[", "i", "]", "=", "(", "IComponentIdentifier", ")", "connector", ".", "getAgentID", "(", "agent_name", "[", "i", "]", ")", ";", "}", "(", "(", "IMessageService", ")", "connector", ".", "getMessageService", "(", ")", ")", ".", "deliverMessage", "(", "hm", ",", "\"fipa\"", ",", "ici", ")", ";", "}" ]
This method sends the same message to many agents. @param agent_name The id of the agents that receive the message @param msgtype @param message_content The content of the message @param connector The connector to get the external access
[ "This", "method", "sends", "the", "same", "message", "to", "many", "agents", "." ]
cc7fdc75cb818c5d60802aaf32c27829e0ca144c
https://github.com/gsi-upm/BeastTool/blob/cc7fdc75cb818c5d60802aaf32c27829e0ca144c/beast-tool/src/main/java/es/upm/dit/gsi/beast/platform/jadex/JadexMessenger.java#L54-L65
train
gsi-upm/BeastTool
beast-tool/src/main/java/es/upm/dit/gsi/beast/platform/jadex/JadexMessenger.java
JadexMessenger.sendMessageToAgentsWithExtraProperties
public void sendMessageToAgentsWithExtraProperties(String[] agent_name, String msgtype, Object message_content, ArrayList<Object> properties, Connector connector) { HashMap<String, Object> hm = new HashMap<String, Object>(); hm.put("performative", msgtype); hm.put(SFipa.CONTENT, message_content); for (Object property : properties) { // Logger logger = Logger.getLogger("JadexMessenger"); // logger.info("Sending message with extra property: "+property.get(0)+", with value "+property.get(1)); hm.put((String) ((Tuple) property).get(0), ((Tuple) property).get(1)); } IComponentIdentifier[] ici = new IComponentIdentifier[agent_name.length]; for (int i = 0; i < agent_name.length; i++) { ici[i] = (IComponentIdentifier) connector.getAgentID(agent_name[i]); } ((IMessageService) connector.getMessageService()).deliverMessage(hm, "fipa", ici); }
java
public void sendMessageToAgentsWithExtraProperties(String[] agent_name, String msgtype, Object message_content, ArrayList<Object> properties, Connector connector) { HashMap<String, Object> hm = new HashMap<String, Object>(); hm.put("performative", msgtype); hm.put(SFipa.CONTENT, message_content); for (Object property : properties) { // Logger logger = Logger.getLogger("JadexMessenger"); // logger.info("Sending message with extra property: "+property.get(0)+", with value "+property.get(1)); hm.put((String) ((Tuple) property).get(0), ((Tuple) property).get(1)); } IComponentIdentifier[] ici = new IComponentIdentifier[agent_name.length]; for (int i = 0; i < agent_name.length; i++) { ici[i] = (IComponentIdentifier) connector.getAgentID(agent_name[i]); } ((IMessageService) connector.getMessageService()).deliverMessage(hm, "fipa", ici); }
[ "public", "void", "sendMessageToAgentsWithExtraProperties", "(", "String", "[", "]", "agent_name", ",", "String", "msgtype", ",", "Object", "message_content", ",", "ArrayList", "<", "Object", ">", "properties", ",", "Connector", "connector", ")", "{", "HashMap", "<", "String", ",", "Object", ">", "hm", "=", "new", "HashMap", "<", "String", ",", "Object", ">", "(", ")", ";", "hm", ".", "put", "(", "\"performative\"", ",", "msgtype", ")", ";", "hm", ".", "put", "(", "SFipa", ".", "CONTENT", ",", "message_content", ")", ";", "for", "(", "Object", "property", ":", "properties", ")", "{", "// Logger logger = Logger.getLogger(\"JadexMessenger\");", "// logger.info(\"Sending message with extra property: \"+property.get(0)+\", with value \"+property.get(1));", "hm", ".", "put", "(", "(", "String", ")", "(", "(", "Tuple", ")", "property", ")", ".", "get", "(", "0", ")", ",", "(", "(", "Tuple", ")", "property", ")", ".", "get", "(", "1", ")", ")", ";", "}", "IComponentIdentifier", "[", "]", "ici", "=", "new", "IComponentIdentifier", "[", "agent_name", ".", "length", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "agent_name", ".", "length", ";", "i", "++", ")", "{", "ici", "[", "i", "]", "=", "(", "IComponentIdentifier", ")", "connector", ".", "getAgentID", "(", "agent_name", "[", "i", "]", ")", ";", "}", "(", "(", "IMessageService", ")", "connector", ".", "getMessageService", "(", ")", ")", ".", "deliverMessage", "(", "hm", ",", "\"fipa\"", ",", "ici", ")", ";", "}" ]
This method works as the one above, adding some properties to the message @param agent_name The id of the agents that receive the message @param msgtype @param message_content The content of the message @param properties to be added to the message @param connector The connector to get the external access
[ "This", "method", "works", "as", "the", "one", "above", "adding", "some", "properties", "to", "the", "message" ]
cc7fdc75cb818c5d60802aaf32c27829e0ca144c
https://github.com/gsi-upm/BeastTool/blob/cc7fdc75cb818c5d60802aaf32c27829e0ca144c/beast-tool/src/main/java/es/upm/dit/gsi/beast/platform/jadex/JadexMessenger.java#L80-L99
train
kuali/ojb-1.0.4
src/java/org/apache/ojb/odmg/TransactionImpl.java
TransactionImpl.lock
public void lock(Object obj, int lockMode) throws LockNotGrantedException { if (log.isDebugEnabled()) log.debug("lock object was called on tx " + this + ", object is " + obj.toString()); checkOpen(); RuntimeObject rtObject = new RuntimeObject(obj, this); lockAndRegister(rtObject, lockMode, isImplicitLocking(), getRegistrationList()); // if(isImplicitLocking()) moveToLastInOrderList(rtObject.getIdentity()); }
java
public void lock(Object obj, int lockMode) throws LockNotGrantedException { if (log.isDebugEnabled()) log.debug("lock object was called on tx " + this + ", object is " + obj.toString()); checkOpen(); RuntimeObject rtObject = new RuntimeObject(obj, this); lockAndRegister(rtObject, lockMode, isImplicitLocking(), getRegistrationList()); // if(isImplicitLocking()) moveToLastInOrderList(rtObject.getIdentity()); }
[ "public", "void", "lock", "(", "Object", "obj", ",", "int", "lockMode", ")", "throws", "LockNotGrantedException", "{", "if", "(", "log", ".", "isDebugEnabled", "(", ")", ")", "log", ".", "debug", "(", "\"lock object was called on tx \"", "+", "this", "+", "\", object is \"", "+", "obj", ".", "toString", "(", ")", ")", ";", "checkOpen", "(", ")", ";", "RuntimeObject", "rtObject", "=", "new", "RuntimeObject", "(", "obj", ",", "this", ")", ";", "lockAndRegister", "(", "rtObject", ",", "lockMode", ",", "isImplicitLocking", "(", ")", ",", "getRegistrationList", "(", ")", ")", ";", "// if(isImplicitLocking()) moveToLastInOrderList(rtObject.getIdentity());\r", "}" ]
Upgrade the lock on the given object to the given lock mode. The call has no effect if the object's current lock is already at or above that level of lock mode. @param obj object to acquire a lock on. @param lockMode lock mode to acquire. The lock modes are <code>READ</code> , <code>UPGRADE</code> , and <code>WRITE</code> . @exception LockNotGrantedException Description of Exception
[ "Upgrade", "the", "lock", "on", "the", "given", "object", "to", "the", "given", "lock", "mode", ".", "The", "call", "has", "no", "effect", "if", "the", "object", "s", "current", "lock", "is", "already", "at", "or", "above", "that", "level", "of", "lock", "mode", "." ]
9a544372f67ce965f662cdc71609dd03683c8f04
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/odmg/TransactionImpl.java#L224-L231
train
kuali/ojb-1.0.4
src/java/org/apache/ojb/odmg/TransactionImpl.java
TransactionImpl.doWriteObjects
protected synchronized void doWriteObjects(boolean isFlush) throws TransactionAbortedException, LockNotGrantedException { /* arminw: if broker isn't in PB-tx, start tx */ if (!getBroker().isInTransaction()) { if (log.isDebugEnabled()) log.debug("call beginTransaction() on PB instance"); broker.beginTransaction(); } // Notify objects of impending commits. performTransactionAwareBeforeCommit(); // Now perfom the real work objectEnvelopeTable.writeObjects(isFlush); // now we have to perform the named objects namedRootsMap.performDeletion(); namedRootsMap.performInsert(); namedRootsMap.afterWriteCleanup(); }
java
protected synchronized void doWriteObjects(boolean isFlush) throws TransactionAbortedException, LockNotGrantedException { /* arminw: if broker isn't in PB-tx, start tx */ if (!getBroker().isInTransaction()) { if (log.isDebugEnabled()) log.debug("call beginTransaction() on PB instance"); broker.beginTransaction(); } // Notify objects of impending commits. performTransactionAwareBeforeCommit(); // Now perfom the real work objectEnvelopeTable.writeObjects(isFlush); // now we have to perform the named objects namedRootsMap.performDeletion(); namedRootsMap.performInsert(); namedRootsMap.afterWriteCleanup(); }
[ "protected", "synchronized", "void", "doWriteObjects", "(", "boolean", "isFlush", ")", "throws", "TransactionAbortedException", ",", "LockNotGrantedException", "{", "/*\r\n arminw:\r\n if broker isn't in PB-tx, start tx\r\n */", "if", "(", "!", "getBroker", "(", ")", ".", "isInTransaction", "(", ")", ")", "{", "if", "(", "log", ".", "isDebugEnabled", "(", ")", ")", "log", ".", "debug", "(", "\"call beginTransaction() on PB instance\"", ")", ";", "broker", ".", "beginTransaction", "(", ")", ";", "}", "// Notify objects of impending commits.\r", "performTransactionAwareBeforeCommit", "(", ")", ";", "// Now perfom the real work\r", "objectEnvelopeTable", ".", "writeObjects", "(", "isFlush", ")", ";", "// now we have to perform the named objects\r", "namedRootsMap", ".", "performDeletion", "(", ")", ";", "namedRootsMap", ".", "performInsert", "(", ")", ";", "namedRootsMap", ".", "afterWriteCleanup", "(", ")", ";", "}" ]
Write objects to data store, but don't release the locks. I don't know what we should do if we are in a checkpoint and we need to abort.
[ "Write", "objects", "to", "data", "store", "but", "don", "t", "release", "the", "locks", ".", "I", "don", "t", "know", "what", "we", "should", "do", "if", "we", "are", "in", "a", "checkpoint", "and", "we", "need", "to", "abort", "." ]
9a544372f67ce965f662cdc71609dd03683c8f04
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/odmg/TransactionImpl.java#L387-L408
train
kuali/ojb-1.0.4
src/java/org/apache/ojb/odmg/TransactionImpl.java
TransactionImpl.doClose
protected synchronized void doClose() { try { LockManager lm = getImplementation().getLockManager(); Enumeration en = objectEnvelopeTable.elements(); while (en.hasMoreElements()) { ObjectEnvelope oe = (ObjectEnvelope) en.nextElement(); lm.releaseLock(this, oe.getIdentity(), oe.getObject()); } //remove locks for objects which haven't been materialized yet for (Iterator it = unmaterializedLocks.iterator(); it.hasNext();) { lm.releaseLock(this, it.next()); } // this tx is no longer interested in materialization callbacks unRegisterFromAllIndirectionHandlers(); unRegisterFromAllCollectionProxies(); } finally { /** * MBAIRD: Be nice and close the table to release all refs */ if (log.isDebugEnabled()) log.debug("Close Transaction and release current PB " + broker + " on tx " + this); // remove current thread from LocalTxManager // to avoid problems for succeeding calls of the same thread implementation.getTxManager().deregisterTx(this); // now cleanup and prepare for reuse refresh(); } }
java
protected synchronized void doClose() { try { LockManager lm = getImplementation().getLockManager(); Enumeration en = objectEnvelopeTable.elements(); while (en.hasMoreElements()) { ObjectEnvelope oe = (ObjectEnvelope) en.nextElement(); lm.releaseLock(this, oe.getIdentity(), oe.getObject()); } //remove locks for objects which haven't been materialized yet for (Iterator it = unmaterializedLocks.iterator(); it.hasNext();) { lm.releaseLock(this, it.next()); } // this tx is no longer interested in materialization callbacks unRegisterFromAllIndirectionHandlers(); unRegisterFromAllCollectionProxies(); } finally { /** * MBAIRD: Be nice and close the table to release all refs */ if (log.isDebugEnabled()) log.debug("Close Transaction and release current PB " + broker + " on tx " + this); // remove current thread from LocalTxManager // to avoid problems for succeeding calls of the same thread implementation.getTxManager().deregisterTx(this); // now cleanup and prepare for reuse refresh(); } }
[ "protected", "synchronized", "void", "doClose", "(", ")", "{", "try", "{", "LockManager", "lm", "=", "getImplementation", "(", ")", ".", "getLockManager", "(", ")", ";", "Enumeration", "en", "=", "objectEnvelopeTable", ".", "elements", "(", ")", ";", "while", "(", "en", ".", "hasMoreElements", "(", ")", ")", "{", "ObjectEnvelope", "oe", "=", "(", "ObjectEnvelope", ")", "en", ".", "nextElement", "(", ")", ";", "lm", ".", "releaseLock", "(", "this", ",", "oe", ".", "getIdentity", "(", ")", ",", "oe", ".", "getObject", "(", ")", ")", ";", "}", "//remove locks for objects which haven't been materialized yet\r", "for", "(", "Iterator", "it", "=", "unmaterializedLocks", ".", "iterator", "(", ")", ";", "it", ".", "hasNext", "(", ")", ";", ")", "{", "lm", ".", "releaseLock", "(", "this", ",", "it", ".", "next", "(", ")", ")", ";", "}", "// this tx is no longer interested in materialization callbacks\r", "unRegisterFromAllIndirectionHandlers", "(", ")", ";", "unRegisterFromAllCollectionProxies", "(", ")", ";", "}", "finally", "{", "/**\r\n * MBAIRD: Be nice and close the table to release all refs\r\n */", "if", "(", "log", ".", "isDebugEnabled", "(", ")", ")", "log", ".", "debug", "(", "\"Close Transaction and release current PB \"", "+", "broker", "+", "\" on tx \"", "+", "this", ")", ";", "// remove current thread from LocalTxManager\r", "// to avoid problems for succeeding calls of the same thread\r", "implementation", ".", "getTxManager", "(", ")", ".", "deregisterTx", "(", "this", ")", ";", "// now cleanup and prepare for reuse\r", "refresh", "(", ")", ";", "}", "}" ]
Close a transaction and do all the cleanup associated with it.
[ "Close", "a", "transaction", "and", "do", "all", "the", "cleanup", "associated", "with", "it", "." ]
9a544372f67ce965f662cdc71609dd03683c8f04
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/odmg/TransactionImpl.java#L430-L465
train
kuali/ojb-1.0.4
src/java/org/apache/ojb/odmg/TransactionImpl.java
TransactionImpl.refresh
protected void refresh() { if (log.isDebugEnabled()) log.debug("Refresh this transaction for reuse: " + this); try { // we reuse ObjectEnvelopeTable instance objectEnvelopeTable.refresh(); } catch (Exception e) { if (log.isDebugEnabled()) { log.debug("error closing object envelope table : " + e.getMessage()); e.printStackTrace(); } } cleanupBroker(); // clear the temporary used named roots map // we should do that, because same tx instance // could be used several times broker = null; clearRegistrationList(); unmaterializedLocks.clear(); txStatus = Status.STATUS_NO_TRANSACTION; }
java
protected void refresh() { if (log.isDebugEnabled()) log.debug("Refresh this transaction for reuse: " + this); try { // we reuse ObjectEnvelopeTable instance objectEnvelopeTable.refresh(); } catch (Exception e) { if (log.isDebugEnabled()) { log.debug("error closing object envelope table : " + e.getMessage()); e.printStackTrace(); } } cleanupBroker(); // clear the temporary used named roots map // we should do that, because same tx instance // could be used several times broker = null; clearRegistrationList(); unmaterializedLocks.clear(); txStatus = Status.STATUS_NO_TRANSACTION; }
[ "protected", "void", "refresh", "(", ")", "{", "if", "(", "log", ".", "isDebugEnabled", "(", ")", ")", "log", ".", "debug", "(", "\"Refresh this transaction for reuse: \"", "+", "this", ")", ";", "try", "{", "// we reuse ObjectEnvelopeTable instance\r", "objectEnvelopeTable", ".", "refresh", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "if", "(", "log", ".", "isDebugEnabled", "(", ")", ")", "{", "log", ".", "debug", "(", "\"error closing object envelope table : \"", "+", "e", ".", "getMessage", "(", ")", ")", ";", "e", ".", "printStackTrace", "(", ")", ";", "}", "}", "cleanupBroker", "(", ")", ";", "// clear the temporary used named roots map\r", "// we should do that, because same tx instance\r", "// could be used several times\r", "broker", "=", "null", ";", "clearRegistrationList", "(", ")", ";", "unmaterializedLocks", ".", "clear", "(", ")", ";", "txStatus", "=", "Status", ".", "STATUS_NO_TRANSACTION", ";", "}" ]
cleanup tx and prepare for reuse
[ "cleanup", "tx", "and", "prepare", "for", "reuse" ]
9a544372f67ce965f662cdc71609dd03683c8f04
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/odmg/TransactionImpl.java#L470-L495
train
kuali/ojb-1.0.4
src/java/org/apache/ojb/odmg/TransactionImpl.java
TransactionImpl.abort
public void abort() { /* do nothing if already rolledback */ if (txStatus == Status.STATUS_NO_TRANSACTION || txStatus == Status.STATUS_UNKNOWN || txStatus == Status.STATUS_ROLLEDBACK) { log.info("Nothing to abort, tx is not active - status is " + TxUtil.getStatusString(txStatus)); return; } // check status of tx if (txStatus != Status.STATUS_ACTIVE && txStatus != Status.STATUS_PREPARED && txStatus != Status.STATUS_MARKED_ROLLBACK) { throw new IllegalStateException("Illegal state for abort call, state was '" + TxUtil.getStatusString(txStatus) + "'"); } if(log.isEnabledFor(Logger.INFO)) { log.info("Abort transaction was called on tx " + this); } try { try { doAbort(); } catch(Exception e) { log.error("Error while abort transaction, will be skipped", e); } // used in managed environments, ignored in non-managed this.implementation.getTxManager().abortExternalTx(this); try { if(hasBroker() && getBroker().isInTransaction()) { getBroker().abortTransaction(); } } catch(Exception e) { log.error("Error while do abort used broker instance, will be skipped", e); } } finally { txStatus = Status.STATUS_ROLLEDBACK; // cleanup things, e.g. release all locks doClose(); } }
java
public void abort() { /* do nothing if already rolledback */ if (txStatus == Status.STATUS_NO_TRANSACTION || txStatus == Status.STATUS_UNKNOWN || txStatus == Status.STATUS_ROLLEDBACK) { log.info("Nothing to abort, tx is not active - status is " + TxUtil.getStatusString(txStatus)); return; } // check status of tx if (txStatus != Status.STATUS_ACTIVE && txStatus != Status.STATUS_PREPARED && txStatus != Status.STATUS_MARKED_ROLLBACK) { throw new IllegalStateException("Illegal state for abort call, state was '" + TxUtil.getStatusString(txStatus) + "'"); } if(log.isEnabledFor(Logger.INFO)) { log.info("Abort transaction was called on tx " + this); } try { try { doAbort(); } catch(Exception e) { log.error("Error while abort transaction, will be skipped", e); } // used in managed environments, ignored in non-managed this.implementation.getTxManager().abortExternalTx(this); try { if(hasBroker() && getBroker().isInTransaction()) { getBroker().abortTransaction(); } } catch(Exception e) { log.error("Error while do abort used broker instance, will be skipped", e); } } finally { txStatus = Status.STATUS_ROLLEDBACK; // cleanup things, e.g. release all locks doClose(); } }
[ "public", "void", "abort", "(", ")", "{", "/*\r\n do nothing if already rolledback\r\n */", "if", "(", "txStatus", "==", "Status", ".", "STATUS_NO_TRANSACTION", "||", "txStatus", "==", "Status", ".", "STATUS_UNKNOWN", "||", "txStatus", "==", "Status", ".", "STATUS_ROLLEDBACK", ")", "{", "log", ".", "info", "(", "\"Nothing to abort, tx is not active - status is \"", "+", "TxUtil", ".", "getStatusString", "(", "txStatus", ")", ")", ";", "return", ";", "}", "// check status of tx\r", "if", "(", "txStatus", "!=", "Status", ".", "STATUS_ACTIVE", "&&", "txStatus", "!=", "Status", ".", "STATUS_PREPARED", "&&", "txStatus", "!=", "Status", ".", "STATUS_MARKED_ROLLBACK", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Illegal state for abort call, state was '\"", "+", "TxUtil", ".", "getStatusString", "(", "txStatus", ")", "+", "\"'\"", ")", ";", "}", "if", "(", "log", ".", "isEnabledFor", "(", "Logger", ".", "INFO", ")", ")", "{", "log", ".", "info", "(", "\"Abort transaction was called on tx \"", "+", "this", ")", ";", "}", "try", "{", "try", "{", "doAbort", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "log", ".", "error", "(", "\"Error while abort transaction, will be skipped\"", ",", "e", ")", ";", "}", "// used in managed environments, ignored in non-managed\r", "this", ".", "implementation", ".", "getTxManager", "(", ")", ".", "abortExternalTx", "(", "this", ")", ";", "try", "{", "if", "(", "hasBroker", "(", ")", "&&", "getBroker", "(", ")", ".", "isInTransaction", "(", ")", ")", "{", "getBroker", "(", ")", ".", "abortTransaction", "(", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "log", ".", "error", "(", "\"Error while do abort used broker instance, will be skipped\"", ",", "e", ")", ";", "}", "}", "finally", "{", "txStatus", "=", "Status", ".", "STATUS_ROLLEDBACK", ";", "// cleanup things, e.g. release all locks\r", "doClose", "(", ")", ";", "}", "}" ]
Abort and close the transaction. Calling abort abandons all persistent object modifications and releases the associated locks. Aborting a transaction does not restore the state of modified transient objects
[ "Abort", "and", "close", "the", "transaction", ".", "Calling", "abort", "abandons", "all", "persistent", "object", "modifications", "and", "releases", "the", "associated", "locks", ".", "Aborting", "a", "transaction", "does", "not", "restore", "the", "state", "of", "modified", "transient", "objects" ]
9a544372f67ce965f662cdc71609dd03683c8f04
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/odmg/TransactionImpl.java#L778-L832
train
kuali/ojb-1.0.4
src/java/org/apache/ojb/odmg/TransactionImpl.java
TransactionImpl.getObjectByIdentity
public Object getObjectByIdentity(Identity id) throws PersistenceBrokerException { checkOpen(); ObjectEnvelope envelope = objectEnvelopeTable.getByIdentity(id); if (envelope != null) { return (envelope.needsDelete() ? null : envelope.getObject()); } else { return getBroker().getObjectByIdentity(id); } }
java
public Object getObjectByIdentity(Identity id) throws PersistenceBrokerException { checkOpen(); ObjectEnvelope envelope = objectEnvelopeTable.getByIdentity(id); if (envelope != null) { return (envelope.needsDelete() ? null : envelope.getObject()); } else { return getBroker().getObjectByIdentity(id); } }
[ "public", "Object", "getObjectByIdentity", "(", "Identity", "id", ")", "throws", "PersistenceBrokerException", "{", "checkOpen", "(", ")", ";", "ObjectEnvelope", "envelope", "=", "objectEnvelopeTable", ".", "getByIdentity", "(", "id", ")", ";", "if", "(", "envelope", "!=", "null", ")", "{", "return", "(", "envelope", ".", "needsDelete", "(", ")", "?", "null", ":", "envelope", ".", "getObject", "(", ")", ")", ";", "}", "else", "{", "return", "getBroker", "(", ")", ".", "getObjectByIdentity", "(", "id", ")", ";", "}", "}" ]
Get object by identity. First lookup among objects registered in the transaction, then in persistent storage. @param id The identity @return The object @throws PersistenceBrokerException
[ "Get", "object", "by", "identity", ".", "First", "lookup", "among", "objects", "registered", "in", "the", "transaction", "then", "in", "persistent", "storage", "." ]
9a544372f67ce965f662cdc71609dd03683c8f04
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/odmg/TransactionImpl.java#L884-L897
train
kuali/ojb-1.0.4
src/java/org/apache/ojb/odmg/TransactionImpl.java
TransactionImpl.lockAndRegisterReferences
private void lockAndRegisterReferences(ClassDescriptor cld, Object sourceObject, int lockMode, List registeredObjects) throws LockNotGrantedException { if (implicitLocking) { Iterator i = cld.getObjectReferenceDescriptors(true).iterator(); while (i.hasNext()) { ObjectReferenceDescriptor rds = (ObjectReferenceDescriptor) i.next(); Object refObj = rds.getPersistentField().get(sourceObject); if (refObj != null) { boolean isProxy = ProxyHelper.isProxy(refObj); RuntimeObject rt = isProxy ? new RuntimeObject(refObj, this, false) : new RuntimeObject(refObj, this); if (!registrationList.contains(rt.getIdentity())) { lockAndRegister(rt, lockMode, registeredObjects); } } } } }
java
private void lockAndRegisterReferences(ClassDescriptor cld, Object sourceObject, int lockMode, List registeredObjects) throws LockNotGrantedException { if (implicitLocking) { Iterator i = cld.getObjectReferenceDescriptors(true).iterator(); while (i.hasNext()) { ObjectReferenceDescriptor rds = (ObjectReferenceDescriptor) i.next(); Object refObj = rds.getPersistentField().get(sourceObject); if (refObj != null) { boolean isProxy = ProxyHelper.isProxy(refObj); RuntimeObject rt = isProxy ? new RuntimeObject(refObj, this, false) : new RuntimeObject(refObj, this); if (!registrationList.contains(rt.getIdentity())) { lockAndRegister(rt, lockMode, registeredObjects); } } } } }
[ "private", "void", "lockAndRegisterReferences", "(", "ClassDescriptor", "cld", ",", "Object", "sourceObject", ",", "int", "lockMode", ",", "List", "registeredObjects", ")", "throws", "LockNotGrantedException", "{", "if", "(", "implicitLocking", ")", "{", "Iterator", "i", "=", "cld", ".", "getObjectReferenceDescriptors", "(", "true", ")", ".", "iterator", "(", ")", ";", "while", "(", "i", ".", "hasNext", "(", ")", ")", "{", "ObjectReferenceDescriptor", "rds", "=", "(", "ObjectReferenceDescriptor", ")", "i", ".", "next", "(", ")", ";", "Object", "refObj", "=", "rds", ".", "getPersistentField", "(", ")", ".", "get", "(", "sourceObject", ")", ";", "if", "(", "refObj", "!=", "null", ")", "{", "boolean", "isProxy", "=", "ProxyHelper", ".", "isProxy", "(", "refObj", ")", ";", "RuntimeObject", "rt", "=", "isProxy", "?", "new", "RuntimeObject", "(", "refObj", ",", "this", ",", "false", ")", ":", "new", "RuntimeObject", "(", "refObj", ",", "this", ")", ";", "if", "(", "!", "registrationList", ".", "contains", "(", "rt", ".", "getIdentity", "(", ")", ")", ")", "{", "lockAndRegister", "(", "rt", ",", "lockMode", ",", "registeredObjects", ")", ";", "}", "}", "}", "}", "}" ]
we only use the registrationList map if the object is not a proxy. During the reference locking, we will materialize objects and they will enter the registered for lock map.
[ "we", "only", "use", "the", "registrationList", "map", "if", "the", "object", "is", "not", "a", "proxy", ".", "During", "the", "reference", "locking", "we", "will", "materialize", "objects", "and", "they", "will", "enter", "the", "registered", "for", "lock", "map", "." ]
9a544372f67ce965f662cdc71609dd03683c8f04
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/odmg/TransactionImpl.java#L983-L1003
train
kuali/ojb-1.0.4
src/java/org/apache/ojb/odmg/TransactionImpl.java
TransactionImpl.afterMaterialization
public void afterMaterialization(IndirectionHandler handler, Object materializedObject) { try { Identity oid = handler.getIdentity(); if (log.isDebugEnabled()) log.debug("deferred registration: " + oid); if(!isOpen()) { log.error("Proxy object materialization outside of a running tx, obj=" + oid); try{throw new Exception("Proxy object materialization outside of a running tx, obj=" + oid);}catch(Exception e) { e.printStackTrace(); } } ClassDescriptor cld = getBroker().getClassDescriptor(materializedObject.getClass()); RuntimeObject rt = new RuntimeObject(materializedObject, oid, cld, false, false); lockAndRegister(rt, Transaction.READ, isImplicitLocking(), getRegistrationList()); } catch (Throwable t) { log.error("Register materialized object with this tx failed", t); throw new LockNotGrantedException(t.getMessage()); } unregisterFromIndirectionHandler(handler); }
java
public void afterMaterialization(IndirectionHandler handler, Object materializedObject) { try { Identity oid = handler.getIdentity(); if (log.isDebugEnabled()) log.debug("deferred registration: " + oid); if(!isOpen()) { log.error("Proxy object materialization outside of a running tx, obj=" + oid); try{throw new Exception("Proxy object materialization outside of a running tx, obj=" + oid);}catch(Exception e) { e.printStackTrace(); } } ClassDescriptor cld = getBroker().getClassDescriptor(materializedObject.getClass()); RuntimeObject rt = new RuntimeObject(materializedObject, oid, cld, false, false); lockAndRegister(rt, Transaction.READ, isImplicitLocking(), getRegistrationList()); } catch (Throwable t) { log.error("Register materialized object with this tx failed", t); throw new LockNotGrantedException(t.getMessage()); } unregisterFromIndirectionHandler(handler); }
[ "public", "void", "afterMaterialization", "(", "IndirectionHandler", "handler", ",", "Object", "materializedObject", ")", "{", "try", "{", "Identity", "oid", "=", "handler", ".", "getIdentity", "(", ")", ";", "if", "(", "log", ".", "isDebugEnabled", "(", ")", ")", "log", ".", "debug", "(", "\"deferred registration: \"", "+", "oid", ")", ";", "if", "(", "!", "isOpen", "(", ")", ")", "{", "log", ".", "error", "(", "\"Proxy object materialization outside of a running tx, obj=\"", "+", "oid", ")", ";", "try", "{", "throw", "new", "Exception", "(", "\"Proxy object materialization outside of a running tx, obj=\"", "+", "oid", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "}", "ClassDescriptor", "cld", "=", "getBroker", "(", ")", ".", "getClassDescriptor", "(", "materializedObject", ".", "getClass", "(", ")", ")", ";", "RuntimeObject", "rt", "=", "new", "RuntimeObject", "(", "materializedObject", ",", "oid", ",", "cld", ",", "false", ",", "false", ")", ";", "lockAndRegister", "(", "rt", ",", "Transaction", ".", "READ", ",", "isImplicitLocking", "(", ")", ",", "getRegistrationList", "(", ")", ")", ";", "}", "catch", "(", "Throwable", "t", ")", "{", "log", ".", "error", "(", "\"Register materialized object with this tx failed\"", ",", "t", ")", ";", "throw", "new", "LockNotGrantedException", "(", "t", ".", "getMessage", "(", ")", ")", ";", "}", "unregisterFromIndirectionHandler", "(", "handler", ")", ";", "}" ]
this callback is invoked after an Object is materialized within an IndirectionHandler. this callback allows to defer registration of objects until it's really neccessary. @param handler the invoking handler @param materializedObject the materialized Object
[ "this", "callback", "is", "invoked", "after", "an", "Object", "is", "materialized", "within", "an", "IndirectionHandler", ".", "this", "callback", "allows", "to", "defer", "registration", "of", "objects", "until", "it", "s", "really", "neccessary", "." ]
9a544372f67ce965f662cdc71609dd03683c8f04
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/odmg/TransactionImpl.java#L1091-L1116
train
kuali/ojb-1.0.4
src/java/org/apache/ojb/odmg/TransactionImpl.java
TransactionImpl.afterLoading
public void afterLoading(CollectionProxyDefaultImpl colProxy) { if (log.isDebugEnabled()) log.debug("loading a proxied collection a collection: " + colProxy); Collection data = colProxy.getData(); for (Iterator iterator = data.iterator(); iterator.hasNext();) { Object o = iterator.next(); if(!isOpen()) { log.error("Collection proxy materialization outside of a running tx, obj=" + o); try{throw new Exception("Collection proxy materialization outside of a running tx, obj=" + o);} catch(Exception e) {e.printStackTrace();} } else { Identity oid = getBroker().serviceIdentity().buildIdentity(o); ClassDescriptor cld = getBroker().getClassDescriptor(ProxyHelper.getRealClass(o)); RuntimeObject rt = new RuntimeObject(o, oid, cld, false, ProxyHelper.isProxy(o)); lockAndRegister(rt, Transaction.READ, isImplicitLocking(), getRegistrationList()); } } unregisterFromCollectionProxy(colProxy); }
java
public void afterLoading(CollectionProxyDefaultImpl colProxy) { if (log.isDebugEnabled()) log.debug("loading a proxied collection a collection: " + colProxy); Collection data = colProxy.getData(); for (Iterator iterator = data.iterator(); iterator.hasNext();) { Object o = iterator.next(); if(!isOpen()) { log.error("Collection proxy materialization outside of a running tx, obj=" + o); try{throw new Exception("Collection proxy materialization outside of a running tx, obj=" + o);} catch(Exception e) {e.printStackTrace();} } else { Identity oid = getBroker().serviceIdentity().buildIdentity(o); ClassDescriptor cld = getBroker().getClassDescriptor(ProxyHelper.getRealClass(o)); RuntimeObject rt = new RuntimeObject(o, oid, cld, false, ProxyHelper.isProxy(o)); lockAndRegister(rt, Transaction.READ, isImplicitLocking(), getRegistrationList()); } } unregisterFromCollectionProxy(colProxy); }
[ "public", "void", "afterLoading", "(", "CollectionProxyDefaultImpl", "colProxy", ")", "{", "if", "(", "log", ".", "isDebugEnabled", "(", ")", ")", "log", ".", "debug", "(", "\"loading a proxied collection a collection: \"", "+", "colProxy", ")", ";", "Collection", "data", "=", "colProxy", ".", "getData", "(", ")", ";", "for", "(", "Iterator", "iterator", "=", "data", ".", "iterator", "(", ")", ";", "iterator", ".", "hasNext", "(", ")", ";", ")", "{", "Object", "o", "=", "iterator", ".", "next", "(", ")", ";", "if", "(", "!", "isOpen", "(", ")", ")", "{", "log", ".", "error", "(", "\"Collection proxy materialization outside of a running tx, obj=\"", "+", "o", ")", ";", "try", "{", "throw", "new", "Exception", "(", "\"Collection proxy materialization outside of a running tx, obj=\"", "+", "o", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "}", "else", "{", "Identity", "oid", "=", "getBroker", "(", ")", ".", "serviceIdentity", "(", ")", ".", "buildIdentity", "(", "o", ")", ";", "ClassDescriptor", "cld", "=", "getBroker", "(", ")", ".", "getClassDescriptor", "(", "ProxyHelper", ".", "getRealClass", "(", "o", ")", ")", ";", "RuntimeObject", "rt", "=", "new", "RuntimeObject", "(", "o", ",", "oid", ",", "cld", ",", "false", ",", "ProxyHelper", ".", "isProxy", "(", "o", ")", ")", ";", "lockAndRegister", "(", "rt", ",", "Transaction", ".", "READ", ",", "isImplicitLocking", "(", ")", ",", "getRegistrationList", "(", ")", ")", ";", "}", "}", "unregisterFromCollectionProxy", "(", "colProxy", ")", ";", "}" ]
Remove colProxy from list of pending collections and register its contents with the transaction.
[ "Remove", "colProxy", "from", "list", "of", "pending", "collections", "and", "register", "its", "contents", "with", "the", "transaction", "." ]
9a544372f67ce965f662cdc71609dd03683c8f04
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/odmg/TransactionImpl.java#L1259-L1282
train
kuali/ojb-1.0.4
src/java/org/apache/ojb/odmg/TransactionImpl.java
TransactionImpl.isTransient
protected boolean isTransient(ClassDescriptor cld, Object obj, Identity oid) { // if the Identity is transient we assume a non-persistent object boolean isNew = oid != null && oid.isTransient(); /* detection of new objects is costly (select of ID in DB to check if object already exists) we do: a. check if the object has nullified PK field b. check if the object is already registered c. lookup from cache and if not found, last option select on DB */ if(!isNew) { final PersistenceBroker pb = getBroker(); if(cld == null) { cld = pb.getClassDescriptor(obj.getClass()); } isNew = pb.serviceBrokerHelper().hasNullPKField(cld, obj); if(!isNew) { if(oid == null) { oid = pb.serviceIdentity().buildIdentity(cld, obj); } final ObjectEnvelope mod = objectEnvelopeTable.getByIdentity(oid); if(mod != null) { // already registered object, use current state isNew = mod.needsInsert(); } else { // if object was found cache, assume it's old // else make costly check against the DB isNew = pb.serviceObjectCache().lookup(oid) == null && !pb.serviceBrokerHelper().doesExist(cld, oid, obj); } } } return isNew; }
java
protected boolean isTransient(ClassDescriptor cld, Object obj, Identity oid) { // if the Identity is transient we assume a non-persistent object boolean isNew = oid != null && oid.isTransient(); /* detection of new objects is costly (select of ID in DB to check if object already exists) we do: a. check if the object has nullified PK field b. check if the object is already registered c. lookup from cache and if not found, last option select on DB */ if(!isNew) { final PersistenceBroker pb = getBroker(); if(cld == null) { cld = pb.getClassDescriptor(obj.getClass()); } isNew = pb.serviceBrokerHelper().hasNullPKField(cld, obj); if(!isNew) { if(oid == null) { oid = pb.serviceIdentity().buildIdentity(cld, obj); } final ObjectEnvelope mod = objectEnvelopeTable.getByIdentity(oid); if(mod != null) { // already registered object, use current state isNew = mod.needsInsert(); } else { // if object was found cache, assume it's old // else make costly check against the DB isNew = pb.serviceObjectCache().lookup(oid) == null && !pb.serviceBrokerHelper().doesExist(cld, oid, obj); } } } return isNew; }
[ "protected", "boolean", "isTransient", "(", "ClassDescriptor", "cld", ",", "Object", "obj", ",", "Identity", "oid", ")", "{", "// if the Identity is transient we assume a non-persistent object\r", "boolean", "isNew", "=", "oid", "!=", "null", "&&", "oid", ".", "isTransient", "(", ")", ";", "/*\r\n detection of new objects is costly (select of ID in DB to check if object\r\n already exists) we do:\r\n a. check if the object has nullified PK field\r\n b. check if the object is already registered\r\n c. lookup from cache and if not found, last option select on DB\r\n */", "if", "(", "!", "isNew", ")", "{", "final", "PersistenceBroker", "pb", "=", "getBroker", "(", ")", ";", "if", "(", "cld", "==", "null", ")", "{", "cld", "=", "pb", ".", "getClassDescriptor", "(", "obj", ".", "getClass", "(", ")", ")", ";", "}", "isNew", "=", "pb", ".", "serviceBrokerHelper", "(", ")", ".", "hasNullPKField", "(", "cld", ",", "obj", ")", ";", "if", "(", "!", "isNew", ")", "{", "if", "(", "oid", "==", "null", ")", "{", "oid", "=", "pb", ".", "serviceIdentity", "(", ")", ".", "buildIdentity", "(", "cld", ",", "obj", ")", ";", "}", "final", "ObjectEnvelope", "mod", "=", "objectEnvelopeTable", ".", "getByIdentity", "(", "oid", ")", ";", "if", "(", "mod", "!=", "null", ")", "{", "// already registered object, use current state\r", "isNew", "=", "mod", ".", "needsInsert", "(", ")", ";", "}", "else", "{", "// if object was found cache, assume it's old\r", "// else make costly check against the DB\r", "isNew", "=", "pb", ".", "serviceObjectCache", "(", ")", ".", "lookup", "(", "oid", ")", "==", "null", "&&", "!", "pb", ".", "serviceBrokerHelper", "(", ")", ".", "doesExist", "(", "cld", ",", "oid", ",", "obj", ")", ";", "}", "}", "}", "return", "isNew", ";", "}" ]
Detect new objects.
[ "Detect", "new", "objects", "." ]
9a544372f67ce965f662cdc71609dd03683c8f04
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/odmg/TransactionImpl.java#L1344-L1385
train
Axway/Grapes
server/src/main/java/org/axway/grapes/server/webapp/views/DependencyListView.java
DependencyListView.getLicense
private License getLicense(final String licenseId) { License result = null; final Set<DbLicense> matchingLicenses = licenseMatcher.getMatchingLicenses(licenseId); if (matchingLicenses.isEmpty()) { result = DataModelFactory.createLicense("#" + licenseId + "# (to be identified)", NOT_IDENTIFIED_YET, NOT_IDENTIFIED_YET, NOT_IDENTIFIED_YET, NOT_IDENTIFIED_YET); result.setUnknown(true); } else { if (matchingLicenses.size() > 1 && LOG.isWarnEnabled()) { LOG.warn(String.format("%s matches multiple licenses %s. " + "Please run the report showing multiple matching on licenses", licenseId, matchingLicenses.toString())); } result = mapper.getLicense(matchingLicenses.iterator().next()); } return result; }
java
private License getLicense(final String licenseId) { License result = null; final Set<DbLicense> matchingLicenses = licenseMatcher.getMatchingLicenses(licenseId); if (matchingLicenses.isEmpty()) { result = DataModelFactory.createLicense("#" + licenseId + "# (to be identified)", NOT_IDENTIFIED_YET, NOT_IDENTIFIED_YET, NOT_IDENTIFIED_YET, NOT_IDENTIFIED_YET); result.setUnknown(true); } else { if (matchingLicenses.size() > 1 && LOG.isWarnEnabled()) { LOG.warn(String.format("%s matches multiple licenses %s. " + "Please run the report showing multiple matching on licenses", licenseId, matchingLicenses.toString())); } result = mapper.getLicense(matchingLicenses.iterator().next()); } return result; }
[ "private", "License", "getLicense", "(", "final", "String", "licenseId", ")", "{", "License", "result", "=", "null", ";", "final", "Set", "<", "DbLicense", ">", "matchingLicenses", "=", "licenseMatcher", ".", "getMatchingLicenses", "(", "licenseId", ")", ";", "if", "(", "matchingLicenses", ".", "isEmpty", "(", ")", ")", "{", "result", "=", "DataModelFactory", ".", "createLicense", "(", "\"#\"", "+", "licenseId", "+", "\"# (to be identified)\"", ",", "NOT_IDENTIFIED_YET", ",", "NOT_IDENTIFIED_YET", ",", "NOT_IDENTIFIED_YET", ",", "NOT_IDENTIFIED_YET", ")", ";", "result", ".", "setUnknown", "(", "true", ")", ";", "}", "else", "{", "if", "(", "matchingLicenses", ".", "size", "(", ")", ">", "1", "&&", "LOG", ".", "isWarnEnabled", "(", ")", ")", "{", "LOG", ".", "warn", "(", "String", ".", "format", "(", "\"%s matches multiple licenses %s. \"", "+", "\"Please run the report showing multiple matching on licenses\"", ",", "licenseId", ",", "matchingLicenses", ".", "toString", "(", ")", ")", ")", ";", "}", "result", "=", "mapper", ".", "getLicense", "(", "matchingLicenses", ".", "iterator", "(", ")", ".", "next", "(", ")", ")", ";", "}", "return", "result", ";", "}" ]
Returns a licenses regarding its Id and a fake on if no license exist with such an Id @param licenseId String @return License
[ "Returns", "a", "licenses", "regarding", "its", "Id", "and", "a", "fake", "on", "if", "no", "license", "exist", "with", "such", "an", "Id" ]
ce9cc73d85f83eaa5fbc991abb593915a8c8374e
https://github.com/Axway/Grapes/blob/ce9cc73d85f83eaa5fbc991abb593915a8c8374e/server/src/main/java/org/axway/grapes/server/webapp/views/DependencyListView.java#L163-L181
train
Axway/Grapes
server/src/main/java/org/axway/grapes/server/webapp/views/DependencyListView.java
DependencyListView.getHeaders
private String[] getHeaders() { final List<String> headers = new ArrayList<>(); if(decorator.getShowSources()){ headers.add(SOURCE_FIELD); } if(decorator.getShowSourcesVersion()){ headers.add(SOURCE_VERSION_FIELD); } if(decorator.getShowTargets()){ headers.add(TARGET_FIELD); } if(decorator.getShowTargetsDownloadUrl()){ headers.add(DOWNLOAD_URL_FIELD); } if(decorator.getShowTargetsSize()){ headers.add(SIZE_FIELD); } if(decorator.getShowScopes()){ headers.add(SCOPE_FIELD); } if(decorator.getShowLicenses()){ headers.add(LICENSE_FIELD); } if(decorator.getShowLicensesLongName()){ headers.add(LICENSE_LONG_NAME_FIELD); } if(decorator.getShowLicensesUrl()){ headers.add(LICENSE_URL_FIELD); } if(decorator.getShowLicensesComment()){ headers.add(LICENSE_COMMENT_FIELD); } return headers.toArray(new String[headers.size()]); }
java
private String[] getHeaders() { final List<String> headers = new ArrayList<>(); if(decorator.getShowSources()){ headers.add(SOURCE_FIELD); } if(decorator.getShowSourcesVersion()){ headers.add(SOURCE_VERSION_FIELD); } if(decorator.getShowTargets()){ headers.add(TARGET_FIELD); } if(decorator.getShowTargetsDownloadUrl()){ headers.add(DOWNLOAD_URL_FIELD); } if(decorator.getShowTargetsSize()){ headers.add(SIZE_FIELD); } if(decorator.getShowScopes()){ headers.add(SCOPE_FIELD); } if(decorator.getShowLicenses()){ headers.add(LICENSE_FIELD); } if(decorator.getShowLicensesLongName()){ headers.add(LICENSE_LONG_NAME_FIELD); } if(decorator.getShowLicensesUrl()){ headers.add(LICENSE_URL_FIELD); } if(decorator.getShowLicensesComment()){ headers.add(LICENSE_COMMENT_FIELD); } return headers.toArray(new String[headers.size()]); }
[ "private", "String", "[", "]", "getHeaders", "(", ")", "{", "final", "List", "<", "String", ">", "headers", "=", "new", "ArrayList", "<>", "(", ")", ";", "if", "(", "decorator", ".", "getShowSources", "(", ")", ")", "{", "headers", ".", "add", "(", "SOURCE_FIELD", ")", ";", "}", "if", "(", "decorator", ".", "getShowSourcesVersion", "(", ")", ")", "{", "headers", ".", "add", "(", "SOURCE_VERSION_FIELD", ")", ";", "}", "if", "(", "decorator", ".", "getShowTargets", "(", ")", ")", "{", "headers", ".", "add", "(", "TARGET_FIELD", ")", ";", "}", "if", "(", "decorator", ".", "getShowTargetsDownloadUrl", "(", ")", ")", "{", "headers", ".", "add", "(", "DOWNLOAD_URL_FIELD", ")", ";", "}", "if", "(", "decorator", ".", "getShowTargetsSize", "(", ")", ")", "{", "headers", ".", "add", "(", "SIZE_FIELD", ")", ";", "}", "if", "(", "decorator", ".", "getShowScopes", "(", ")", ")", "{", "headers", ".", "add", "(", "SCOPE_FIELD", ")", ";", "}", "if", "(", "decorator", ".", "getShowLicenses", "(", ")", ")", "{", "headers", ".", "add", "(", "LICENSE_FIELD", ")", ";", "}", "if", "(", "decorator", ".", "getShowLicensesLongName", "(", ")", ")", "{", "headers", ".", "add", "(", "LICENSE_LONG_NAME_FIELD", ")", ";", "}", "if", "(", "decorator", ".", "getShowLicensesUrl", "(", ")", ")", "{", "headers", ".", "add", "(", "LICENSE_URL_FIELD", ")", ";", "}", "if", "(", "decorator", ".", "getShowLicensesComment", "(", ")", ")", "{", "headers", ".", "add", "(", "LICENSE_COMMENT_FIELD", ")", ";", "}", "return", "headers", ".", "toArray", "(", "new", "String", "[", "headers", ".", "size", "(", ")", "]", ")", ";", "}" ]
Init the headers of the table regarding the filters @return String[]
[ "Init", "the", "headers", "of", "the", "table", "regarding", "the", "filters" ]
ce9cc73d85f83eaa5fbc991abb593915a8c8374e
https://github.com/Axway/Grapes/blob/ce9cc73d85f83eaa5fbc991abb593915a8c8374e/server/src/main/java/org/axway/grapes/server/webapp/views/DependencyListView.java#L188-L232
train
geomajas/geomajas-project-server
plugin/layer-common/layer-common/src/main/java/org/geomajas/layer/common/proxy/CachingLayerHttpService.java
CachingLayerHttpService.getStream
public InputStream getStream(String url, RasterLayer layer) throws IOException { if (layer instanceof ProxyLayerSupport) { ProxyLayerSupport proxyLayer = (ProxyLayerSupport) layer; if (proxyLayer.isUseCache() && null != cacheManagerService) { Object cachedObject = cacheManagerService.get(proxyLayer, CacheCategory.RASTER, url); if (null != cachedObject) { testRecorder.record(TEST_RECORDER_GROUP, TEST_RECORDER_GET_FROM_CACHE); return new ByteArrayInputStream((byte[]) cachedObject); } else { testRecorder.record(TEST_RECORDER_GROUP, TEST_RECORDER_PUT_IN_CACHE); InputStream stream = super.getStream(url, proxyLayer); ByteArrayOutputStream os = new ByteArrayOutputStream(); int b; while ((b = stream.read()) >= 0) { os.write(b); } cacheManagerService.put(proxyLayer, CacheCategory.RASTER, url, os.toByteArray(), getLayerEnvelope(proxyLayer)); return new ByteArrayInputStream((byte[]) os.toByteArray()); } } } return super.getStream(url, layer); }
java
public InputStream getStream(String url, RasterLayer layer) throws IOException { if (layer instanceof ProxyLayerSupport) { ProxyLayerSupport proxyLayer = (ProxyLayerSupport) layer; if (proxyLayer.isUseCache() && null != cacheManagerService) { Object cachedObject = cacheManagerService.get(proxyLayer, CacheCategory.RASTER, url); if (null != cachedObject) { testRecorder.record(TEST_RECORDER_GROUP, TEST_RECORDER_GET_FROM_CACHE); return new ByteArrayInputStream((byte[]) cachedObject); } else { testRecorder.record(TEST_RECORDER_GROUP, TEST_RECORDER_PUT_IN_CACHE); InputStream stream = super.getStream(url, proxyLayer); ByteArrayOutputStream os = new ByteArrayOutputStream(); int b; while ((b = stream.read()) >= 0) { os.write(b); } cacheManagerService.put(proxyLayer, CacheCategory.RASTER, url, os.toByteArray(), getLayerEnvelope(proxyLayer)); return new ByteArrayInputStream((byte[]) os.toByteArray()); } } } return super.getStream(url, layer); }
[ "public", "InputStream", "getStream", "(", "String", "url", ",", "RasterLayer", "layer", ")", "throws", "IOException", "{", "if", "(", "layer", "instanceof", "ProxyLayerSupport", ")", "{", "ProxyLayerSupport", "proxyLayer", "=", "(", "ProxyLayerSupport", ")", "layer", ";", "if", "(", "proxyLayer", ".", "isUseCache", "(", ")", "&&", "null", "!=", "cacheManagerService", ")", "{", "Object", "cachedObject", "=", "cacheManagerService", ".", "get", "(", "proxyLayer", ",", "CacheCategory", ".", "RASTER", ",", "url", ")", ";", "if", "(", "null", "!=", "cachedObject", ")", "{", "testRecorder", ".", "record", "(", "TEST_RECORDER_GROUP", ",", "TEST_RECORDER_GET_FROM_CACHE", ")", ";", "return", "new", "ByteArrayInputStream", "(", "(", "byte", "[", "]", ")", "cachedObject", ")", ";", "}", "else", "{", "testRecorder", ".", "record", "(", "TEST_RECORDER_GROUP", ",", "TEST_RECORDER_PUT_IN_CACHE", ")", ";", "InputStream", "stream", "=", "super", ".", "getStream", "(", "url", ",", "proxyLayer", ")", ";", "ByteArrayOutputStream", "os", "=", "new", "ByteArrayOutputStream", "(", ")", ";", "int", "b", ";", "while", "(", "(", "b", "=", "stream", ".", "read", "(", ")", ")", ">=", "0", ")", "{", "os", ".", "write", "(", "b", ")", ";", "}", "cacheManagerService", ".", "put", "(", "proxyLayer", ",", "CacheCategory", ".", "RASTER", ",", "url", ",", "os", ".", "toByteArray", "(", ")", ",", "getLayerEnvelope", "(", "proxyLayer", ")", ")", ";", "return", "new", "ByteArrayInputStream", "(", "(", "byte", "[", "]", ")", "os", ".", "toByteArray", "(", ")", ")", ";", "}", "}", "}", "return", "super", ".", "getStream", "(", "url", ",", "layer", ")", ";", "}" ]
Get the contents from the request URL. @param url URL to get the response from @param layer the raster layer @return {@link InputStream} with the content @throws IOException cannot get content
[ "Get", "the", "contents", "from", "the", "request", "URL", "." ]
904b7d7deed1350d28955589098dd1e0a786d76e
https://github.com/geomajas/geomajas-project-server/blob/904b7d7deed1350d28955589098dd1e0a786d76e/plugin/layer-common/layer-common/src/main/java/org/geomajas/layer/common/proxy/CachingLayerHttpService.java#L69-L92
train
geomajas/geomajas-project-server
plugin/layer-common/layer-common/src/main/java/org/geomajas/layer/common/proxy/CachingLayerHttpService.java
CachingLayerHttpService.getLayerEnvelope
private Envelope getLayerEnvelope(ProxyLayerSupport layer) { Bbox bounds = layer.getLayerInfo().getMaxExtent(); return new Envelope(bounds.getX(), bounds.getMaxX(), bounds.getY(), bounds.getMaxY()); }
java
private Envelope getLayerEnvelope(ProxyLayerSupport layer) { Bbox bounds = layer.getLayerInfo().getMaxExtent(); return new Envelope(bounds.getX(), bounds.getMaxX(), bounds.getY(), bounds.getMaxY()); }
[ "private", "Envelope", "getLayerEnvelope", "(", "ProxyLayerSupport", "layer", ")", "{", "Bbox", "bounds", "=", "layer", ".", "getLayerInfo", "(", ")", ".", "getMaxExtent", "(", ")", ";", "return", "new", "Envelope", "(", "bounds", ".", "getX", "(", ")", ",", "bounds", ".", "getMaxX", "(", ")", ",", "bounds", ".", "getY", "(", ")", ",", "bounds", ".", "getMaxY", "(", ")", ")", ";", "}" ]
Return the max bounds of the layer as envelope. @param layer the layer to get envelope from @return Envelope the envelope
[ "Return", "the", "max", "bounds", "of", "the", "layer", "as", "envelope", "." ]
904b7d7deed1350d28955589098dd1e0a786d76e
https://github.com/geomajas/geomajas-project-server/blob/904b7d7deed1350d28955589098dd1e0a786d76e/plugin/layer-common/layer-common/src/main/java/org/geomajas/layer/common/proxy/CachingLayerHttpService.java#L100-L103
train
Axway/Grapes
server/src/main/java/org/axway/grapes/server/webapp/resources/PromotionReportTranslator.java
PromotionReportTranslator.buildErrorMsg
private static String buildErrorMsg(List<String> dependencies, String message) { final StringBuilder buffer = new StringBuilder(); boolean isFirstElement = true; for (String dependency : dependencies) { if (!isFirstElement) { buffer.append(", "); } // check if it is an instance of Artifact - add the gavc else append the object buffer.append(dependency); isFirstElement = false; } return String.format(message, buffer.toString()); }
java
private static String buildErrorMsg(List<String> dependencies, String message) { final StringBuilder buffer = new StringBuilder(); boolean isFirstElement = true; for (String dependency : dependencies) { if (!isFirstElement) { buffer.append(", "); } // check if it is an instance of Artifact - add the gavc else append the object buffer.append(dependency); isFirstElement = false; } return String.format(message, buffer.toString()); }
[ "private", "static", "String", "buildErrorMsg", "(", "List", "<", "String", ">", "dependencies", ",", "String", "message", ")", "{", "final", "StringBuilder", "buffer", "=", "new", "StringBuilder", "(", ")", ";", "boolean", "isFirstElement", "=", "true", ";", "for", "(", "String", "dependency", ":", "dependencies", ")", "{", "if", "(", "!", "isFirstElement", ")", "{", "buffer", ".", "append", "(", "\", \"", ")", ";", "}", "// check if it is an instance of Artifact - add the gavc else append the object", "buffer", ".", "append", "(", "dependency", ")", ";", "isFirstElement", "=", "false", ";", "}", "return", "String", ".", "format", "(", "message", ",", "buffer", ".", "toString", "(", ")", ")", ";", "}" ]
Get the error message with the dependencies appended @param dependencies - the list with dependencies to be attached to the message @param message - the custom error message to be displayed to the user @return String
[ "Get", "the", "error", "message", "with", "the", "dependencies", "appended" ]
ce9cc73d85f83eaa5fbc991abb593915a8c8374e
https://github.com/Axway/Grapes/blob/ce9cc73d85f83eaa5fbc991abb593915a8c8374e/server/src/main/java/org/axway/grapes/server/webapp/resources/PromotionReportTranslator.java#L161-L174
train
kuali/ojb-1.0.4
src/java/org/apache/ojb/broker/accesslayer/CollectionPrefetcher.java
CollectionPrefetcher.buildPrefetchQuery
protected Query buildPrefetchQuery(Collection ids) { CollectionDescriptor cds = getCollectionDescriptor(); QueryByCriteria query = buildPrefetchQuery(ids, cds.getForeignKeyFieldDescriptors(getItemClassDescriptor())); // check if collection must be ordered if (!cds.getOrderBy().isEmpty()) { Iterator iter = cds.getOrderBy().iterator(); while (iter.hasNext()) { query.addOrderBy((FieldHelper) iter.next()); } } return query; }
java
protected Query buildPrefetchQuery(Collection ids) { CollectionDescriptor cds = getCollectionDescriptor(); QueryByCriteria query = buildPrefetchQuery(ids, cds.getForeignKeyFieldDescriptors(getItemClassDescriptor())); // check if collection must be ordered if (!cds.getOrderBy().isEmpty()) { Iterator iter = cds.getOrderBy().iterator(); while (iter.hasNext()) { query.addOrderBy((FieldHelper) iter.next()); } } return query; }
[ "protected", "Query", "buildPrefetchQuery", "(", "Collection", "ids", ")", "{", "CollectionDescriptor", "cds", "=", "getCollectionDescriptor", "(", ")", ";", "QueryByCriteria", "query", "=", "buildPrefetchQuery", "(", "ids", ",", "cds", ".", "getForeignKeyFieldDescriptors", "(", "getItemClassDescriptor", "(", ")", ")", ")", ";", "// check if collection must be ordered\r", "if", "(", "!", "cds", ".", "getOrderBy", "(", ")", ".", "isEmpty", "(", ")", ")", "{", "Iterator", "iter", "=", "cds", ".", "getOrderBy", "(", ")", ".", "iterator", "(", ")", ";", "while", "(", "iter", ".", "hasNext", "(", ")", ")", "{", "query", ".", "addOrderBy", "(", "(", "FieldHelper", ")", "iter", ".", "next", "(", ")", ")", ";", "}", "}", "return", "query", ";", "}" ]
Build the query to perform a batched read get orderBy settings from CollectionDescriptor @param ids Collection containing all identities of objects of the ONE side
[ "Build", "the", "query", "to", "perform", "a", "batched", "read", "get", "orderBy", "settings", "from", "CollectionDescriptor" ]
9a544372f67ce965f662cdc71609dd03683c8f04
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/accesslayer/CollectionPrefetcher.java#L110-L126
train
kuali/ojb-1.0.4
src/java/org/apache/ojb/broker/accesslayer/CollectionPrefetcher.java
CollectionPrefetcher.associateBatched
protected void associateBatched(Collection owners, Collection children) { CollectionDescriptor cds = getCollectionDescriptor(); PersistentField field = cds.getPersistentField(); PersistenceBroker pb = getBroker(); Class ownerTopLevelClass = pb.getTopLevelClass(getOwnerClassDescriptor().getClassOfObject()); Class collectionClass = cds.getCollectionClass(); // this collection type will be used: HashMap ownerIdsToLists = new HashMap(owners.size()); IdentityFactory identityFactory = pb.serviceIdentity(); // initialize the owner list map for (Iterator it = owners.iterator(); it.hasNext();) { Object owner = it.next(); ownerIdsToLists.put(identityFactory.buildIdentity(getOwnerClassDescriptor(), owner), new ArrayList()); } // build the children lists for the owners for (Iterator it = children.iterator(); it.hasNext();) { Object child = it.next(); // BRJ: use cld for real class, relatedObject could be Proxy ClassDescriptor cld = getDescriptorRepository().getDescriptorFor(ProxyHelper.getRealClass(child)); Object[] fkValues = cds.getForeignKeyValues(child, cld); Identity ownerId = identityFactory.buildIdentity(null, ownerTopLevelClass, fkValues); List list = (List) ownerIdsToLists.get(ownerId); if (list != null) { list.add(child); } } // connect children list to owners for (Iterator it = owners.iterator(); it.hasNext();) { Object result; Object owner = it.next(); Identity ownerId = identityFactory.buildIdentity(owner); List list = (List) ownerIdsToLists.get(ownerId); if ((collectionClass == null) && field.getType().isArray()) { int length = list.size(); Class itemtype = field.getType().getComponentType(); result = Array.newInstance(itemtype, length); for (int j = 0; j < length; j++) { Array.set(result, j, list.get(j)); } } else { ManageableCollection col = createCollection(cds, collectionClass); for (Iterator it2 = list.iterator(); it2.hasNext();) { col.ojbAdd(it2.next()); } result = col; } Object value = field.get(owner); if ((value instanceof CollectionProxyDefaultImpl) && (result instanceof Collection)) { ((CollectionProxyDefaultImpl) value).setData((Collection) result); } else { field.set(owner, result); } } }
java
protected void associateBatched(Collection owners, Collection children) { CollectionDescriptor cds = getCollectionDescriptor(); PersistentField field = cds.getPersistentField(); PersistenceBroker pb = getBroker(); Class ownerTopLevelClass = pb.getTopLevelClass(getOwnerClassDescriptor().getClassOfObject()); Class collectionClass = cds.getCollectionClass(); // this collection type will be used: HashMap ownerIdsToLists = new HashMap(owners.size()); IdentityFactory identityFactory = pb.serviceIdentity(); // initialize the owner list map for (Iterator it = owners.iterator(); it.hasNext();) { Object owner = it.next(); ownerIdsToLists.put(identityFactory.buildIdentity(getOwnerClassDescriptor(), owner), new ArrayList()); } // build the children lists for the owners for (Iterator it = children.iterator(); it.hasNext();) { Object child = it.next(); // BRJ: use cld for real class, relatedObject could be Proxy ClassDescriptor cld = getDescriptorRepository().getDescriptorFor(ProxyHelper.getRealClass(child)); Object[] fkValues = cds.getForeignKeyValues(child, cld); Identity ownerId = identityFactory.buildIdentity(null, ownerTopLevelClass, fkValues); List list = (List) ownerIdsToLists.get(ownerId); if (list != null) { list.add(child); } } // connect children list to owners for (Iterator it = owners.iterator(); it.hasNext();) { Object result; Object owner = it.next(); Identity ownerId = identityFactory.buildIdentity(owner); List list = (List) ownerIdsToLists.get(ownerId); if ((collectionClass == null) && field.getType().isArray()) { int length = list.size(); Class itemtype = field.getType().getComponentType(); result = Array.newInstance(itemtype, length); for (int j = 0; j < length; j++) { Array.set(result, j, list.get(j)); } } else { ManageableCollection col = createCollection(cds, collectionClass); for (Iterator it2 = list.iterator(); it2.hasNext();) { col.ojbAdd(it2.next()); } result = col; } Object value = field.get(owner); if ((value instanceof CollectionProxyDefaultImpl) && (result instanceof Collection)) { ((CollectionProxyDefaultImpl) value).setData((Collection) result); } else { field.set(owner, result); } } }
[ "protected", "void", "associateBatched", "(", "Collection", "owners", ",", "Collection", "children", ")", "{", "CollectionDescriptor", "cds", "=", "getCollectionDescriptor", "(", ")", ";", "PersistentField", "field", "=", "cds", ".", "getPersistentField", "(", ")", ";", "PersistenceBroker", "pb", "=", "getBroker", "(", ")", ";", "Class", "ownerTopLevelClass", "=", "pb", ".", "getTopLevelClass", "(", "getOwnerClassDescriptor", "(", ")", ".", "getClassOfObject", "(", ")", ")", ";", "Class", "collectionClass", "=", "cds", ".", "getCollectionClass", "(", ")", ";", "// this collection type will be used:\r", "HashMap", "ownerIdsToLists", "=", "new", "HashMap", "(", "owners", ".", "size", "(", ")", ")", ";", "IdentityFactory", "identityFactory", "=", "pb", ".", "serviceIdentity", "(", ")", ";", "// initialize the owner list map\r", "for", "(", "Iterator", "it", "=", "owners", ".", "iterator", "(", ")", ";", "it", ".", "hasNext", "(", ")", ";", ")", "{", "Object", "owner", "=", "it", ".", "next", "(", ")", ";", "ownerIdsToLists", ".", "put", "(", "identityFactory", ".", "buildIdentity", "(", "getOwnerClassDescriptor", "(", ")", ",", "owner", ")", ",", "new", "ArrayList", "(", ")", ")", ";", "}", "// build the children lists for the owners\r", "for", "(", "Iterator", "it", "=", "children", ".", "iterator", "(", ")", ";", "it", ".", "hasNext", "(", ")", ";", ")", "{", "Object", "child", "=", "it", ".", "next", "(", ")", ";", "// BRJ: use cld for real class, relatedObject could be Proxy\r", "ClassDescriptor", "cld", "=", "getDescriptorRepository", "(", ")", ".", "getDescriptorFor", "(", "ProxyHelper", ".", "getRealClass", "(", "child", ")", ")", ";", "Object", "[", "]", "fkValues", "=", "cds", ".", "getForeignKeyValues", "(", "child", ",", "cld", ")", ";", "Identity", "ownerId", "=", "identityFactory", ".", "buildIdentity", "(", "null", ",", "ownerTopLevelClass", ",", "fkValues", ")", ";", "List", "list", "=", "(", "List", ")", "ownerIdsToLists", ".", "get", "(", "ownerId", ")", ";", "if", "(", "list", "!=", "null", ")", "{", "list", ".", "add", "(", "child", ")", ";", "}", "}", "// connect children list to owners\r", "for", "(", "Iterator", "it", "=", "owners", ".", "iterator", "(", ")", ";", "it", ".", "hasNext", "(", ")", ";", ")", "{", "Object", "result", ";", "Object", "owner", "=", "it", ".", "next", "(", ")", ";", "Identity", "ownerId", "=", "identityFactory", ".", "buildIdentity", "(", "owner", ")", ";", "List", "list", "=", "(", "List", ")", "ownerIdsToLists", ".", "get", "(", "ownerId", ")", ";", "if", "(", "(", "collectionClass", "==", "null", ")", "&&", "field", ".", "getType", "(", ")", ".", "isArray", "(", ")", ")", "{", "int", "length", "=", "list", ".", "size", "(", ")", ";", "Class", "itemtype", "=", "field", ".", "getType", "(", ")", ".", "getComponentType", "(", ")", ";", "result", "=", "Array", ".", "newInstance", "(", "itemtype", ",", "length", ")", ";", "for", "(", "int", "j", "=", "0", ";", "j", "<", "length", ";", "j", "++", ")", "{", "Array", ".", "set", "(", "result", ",", "j", ",", "list", ".", "get", "(", "j", ")", ")", ";", "}", "}", "else", "{", "ManageableCollection", "col", "=", "createCollection", "(", "cds", ",", "collectionClass", ")", ";", "for", "(", "Iterator", "it2", "=", "list", ".", "iterator", "(", ")", ";", "it2", ".", "hasNext", "(", ")", ";", ")", "{", "col", ".", "ojbAdd", "(", "it2", ".", "next", "(", ")", ")", ";", "}", "result", "=", "col", ";", "}", "Object", "value", "=", "field", ".", "get", "(", "owner", ")", ";", "if", "(", "(", "value", "instanceof", "CollectionProxyDefaultImpl", ")", "&&", "(", "result", "instanceof", "Collection", ")", ")", "{", "(", "(", "CollectionProxyDefaultImpl", ")", "value", ")", ".", "setData", "(", "(", "Collection", ")", "result", ")", ";", "}", "else", "{", "field", ".", "set", "(", "owner", ",", "result", ")", ";", "}", "}", "}" ]
associate the batched Children with their owner object loop over children
[ "associate", "the", "batched", "Children", "with", "their", "owner", "object", "loop", "over", "children" ]
9a544372f67ce965f662cdc71609dd03683c8f04
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/accesslayer/CollectionPrefetcher.java#L131-L202
train
kuali/ojb-1.0.4
src/java/org/apache/ojb/broker/accesslayer/CollectionPrefetcher.java
CollectionPrefetcher.createCollection
protected ManageableCollection createCollection(CollectionDescriptor desc, Class collectionClass) { Class fieldType = desc.getPersistentField().getType(); ManageableCollection col; if (collectionClass == null) { if (ManageableCollection.class.isAssignableFrom(fieldType)) { try { col = (ManageableCollection)fieldType.newInstance(); } catch (Exception e) { throw new OJBRuntimeException("Cannot instantiate the default collection type "+fieldType.getName()+" of collection "+desc.getAttributeName()+" in type "+desc.getClassDescriptor().getClassNameOfObject()); } } else if (fieldType.isAssignableFrom(RemovalAwareCollection.class)) { col = new RemovalAwareCollection(); } else if (fieldType.isAssignableFrom(RemovalAwareList.class)) { col = new RemovalAwareList(); } else if (fieldType.isAssignableFrom(RemovalAwareSet.class)) { col = new RemovalAwareSet(); } else { throw new MetadataException("Cannot determine a default collection type for collection "+desc.getAttributeName()+" in type "+desc.getClassDescriptor().getClassNameOfObject()); } } else { try { col = (ManageableCollection)collectionClass.newInstance(); } catch (Exception e) { throw new OJBRuntimeException("Cannot instantiate the collection class "+collectionClass.getName()+" of collection "+desc.getAttributeName()+" in type "+desc.getClassDescriptor().getClassNameOfObject()); } } return col; }
java
protected ManageableCollection createCollection(CollectionDescriptor desc, Class collectionClass) { Class fieldType = desc.getPersistentField().getType(); ManageableCollection col; if (collectionClass == null) { if (ManageableCollection.class.isAssignableFrom(fieldType)) { try { col = (ManageableCollection)fieldType.newInstance(); } catch (Exception e) { throw new OJBRuntimeException("Cannot instantiate the default collection type "+fieldType.getName()+" of collection "+desc.getAttributeName()+" in type "+desc.getClassDescriptor().getClassNameOfObject()); } } else if (fieldType.isAssignableFrom(RemovalAwareCollection.class)) { col = new RemovalAwareCollection(); } else if (fieldType.isAssignableFrom(RemovalAwareList.class)) { col = new RemovalAwareList(); } else if (fieldType.isAssignableFrom(RemovalAwareSet.class)) { col = new RemovalAwareSet(); } else { throw new MetadataException("Cannot determine a default collection type for collection "+desc.getAttributeName()+" in type "+desc.getClassDescriptor().getClassNameOfObject()); } } else { try { col = (ManageableCollection)collectionClass.newInstance(); } catch (Exception e) { throw new OJBRuntimeException("Cannot instantiate the collection class "+collectionClass.getName()+" of collection "+desc.getAttributeName()+" in type "+desc.getClassDescriptor().getClassNameOfObject()); } } return col; }
[ "protected", "ManageableCollection", "createCollection", "(", "CollectionDescriptor", "desc", ",", "Class", "collectionClass", ")", "{", "Class", "fieldType", "=", "desc", ".", "getPersistentField", "(", ")", ".", "getType", "(", ")", ";", "ManageableCollection", "col", ";", "if", "(", "collectionClass", "==", "null", ")", "{", "if", "(", "ManageableCollection", ".", "class", ".", "isAssignableFrom", "(", "fieldType", ")", ")", "{", "try", "{", "col", "=", "(", "ManageableCollection", ")", "fieldType", ".", "newInstance", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "OJBRuntimeException", "(", "\"Cannot instantiate the default collection type \"", "+", "fieldType", ".", "getName", "(", ")", "+", "\" of collection \"", "+", "desc", ".", "getAttributeName", "(", ")", "+", "\" in type \"", "+", "desc", ".", "getClassDescriptor", "(", ")", ".", "getClassNameOfObject", "(", ")", ")", ";", "}", "}", "else", "if", "(", "fieldType", ".", "isAssignableFrom", "(", "RemovalAwareCollection", ".", "class", ")", ")", "{", "col", "=", "new", "RemovalAwareCollection", "(", ")", ";", "}", "else", "if", "(", "fieldType", ".", "isAssignableFrom", "(", "RemovalAwareList", ".", "class", ")", ")", "{", "col", "=", "new", "RemovalAwareList", "(", ")", ";", "}", "else", "if", "(", "fieldType", ".", "isAssignableFrom", "(", "RemovalAwareSet", ".", "class", ")", ")", "{", "col", "=", "new", "RemovalAwareSet", "(", ")", ";", "}", "else", "{", "throw", "new", "MetadataException", "(", "\"Cannot determine a default collection type for collection \"", "+", "desc", ".", "getAttributeName", "(", ")", "+", "\" in type \"", "+", "desc", ".", "getClassDescriptor", "(", ")", ".", "getClassNameOfObject", "(", ")", ")", ";", "}", "}", "else", "{", "try", "{", "col", "=", "(", "ManageableCollection", ")", "collectionClass", ".", "newInstance", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "OJBRuntimeException", "(", "\"Cannot instantiate the collection class \"", "+", "collectionClass", ".", "getName", "(", ")", "+", "\" of collection \"", "+", "desc", ".", "getAttributeName", "(", ")", "+", "\" in type \"", "+", "desc", ".", "getClassDescriptor", "(", ")", ".", "getClassNameOfObject", "(", ")", ")", ";", "}", "}", "return", "col", ";", "}" ]
Create a collection object of the given collection type. If none has been given, OJB uses RemovalAwareList, RemovalAwareSet, or RemovalAwareCollection depending on the field type. @param desc The collection descriptor @param collectionClass The collection class specified in the collection-descriptor @return The collection object
[ "Create", "a", "collection", "object", "of", "the", "given", "collection", "type", ".", "If", "none", "has", "been", "given", "OJB", "uses", "RemovalAwareList", "RemovalAwareSet", "or", "RemovalAwareCollection", "depending", "on", "the", "field", "type", "." ]
9a544372f67ce965f662cdc71609dd03683c8f04
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/accesslayer/CollectionPrefetcher.java#L213-L260
train
geomajas/geomajas-project-server
plugin/layer-hibernate/hibernate/src/main/java/org/geomajas/layer/hibernate/HibernateLayer.java
HibernateLayer.setFeatureModel
@Api public void setFeatureModel(FeatureModel featureModel) throws LayerException { this.featureModel = featureModel; if (null != getLayerInfo()) { featureModel.setLayerInfo(getLayerInfo()); } filterService.registerFeatureModel(featureModel); }
java
@Api public void setFeatureModel(FeatureModel featureModel) throws LayerException { this.featureModel = featureModel; if (null != getLayerInfo()) { featureModel.setLayerInfo(getLayerInfo()); } filterService.registerFeatureModel(featureModel); }
[ "@", "Api", "public", "void", "setFeatureModel", "(", "FeatureModel", "featureModel", ")", "throws", "LayerException", "{", "this", ".", "featureModel", "=", "featureModel", ";", "if", "(", "null", "!=", "getLayerInfo", "(", ")", ")", "{", "featureModel", ".", "setLayerInfo", "(", "getLayerInfo", "(", ")", ")", ";", "}", "filterService", ".", "registerFeatureModel", "(", "featureModel", ")", ";", "}" ]
Set the featureModel. @param featureModel feature model @throws LayerException problem setting the feature model @since 1.8.0
[ "Set", "the", "featureModel", "." ]
904b7d7deed1350d28955589098dd1e0a786d76e
https://github.com/geomajas/geomajas-project-server/blob/904b7d7deed1350d28955589098dd1e0a786d76e/plugin/layer-hibernate/hibernate/src/main/java/org/geomajas/layer/hibernate/HibernateLayer.java#L208-L215
train
geomajas/geomajas-project-server
plugin/layer-hibernate/hibernate/src/main/java/org/geomajas/layer/hibernate/HibernateLayer.java
HibernateLayer.update
public void update(Object feature) throws LayerException { Session session = getSessionFactory().getCurrentSession(); session.update(feature); }
java
public void update(Object feature) throws LayerException { Session session = getSessionFactory().getCurrentSession(); session.update(feature); }
[ "public", "void", "update", "(", "Object", "feature", ")", "throws", "LayerException", "{", "Session", "session", "=", "getSessionFactory", "(", ")", ".", "getCurrentSession", "(", ")", ";", "session", ".", "update", "(", "feature", ")", ";", "}" ]
Update a feature object in the Hibernate session. @param feature feature object @throws LayerException oops
[ "Update", "a", "feature", "object", "in", "the", "Hibernate", "session", "." ]
904b7d7deed1350d28955589098dd1e0a786d76e
https://github.com/geomajas/geomajas-project-server/blob/904b7d7deed1350d28955589098dd1e0a786d76e/plugin/layer-hibernate/hibernate/src/main/java/org/geomajas/layer/hibernate/HibernateLayer.java#L313-L316
train
geomajas/geomajas-project-server
plugin/layer-hibernate/hibernate/src/main/java/org/geomajas/layer/hibernate/HibernateLayer.java
HibernateLayer.enforceSrid
private void enforceSrid(Object feature) throws LayerException { Geometry geom = getFeatureModel().getGeometry(feature); if (null != geom) { geom.setSRID(srid); getFeatureModel().setGeometry(feature, geom); } }
java
private void enforceSrid(Object feature) throws LayerException { Geometry geom = getFeatureModel().getGeometry(feature); if (null != geom) { geom.setSRID(srid); getFeatureModel().setGeometry(feature, geom); } }
[ "private", "void", "enforceSrid", "(", "Object", "feature", ")", "throws", "LayerException", "{", "Geometry", "geom", "=", "getFeatureModel", "(", ")", ".", "getGeometry", "(", "feature", ")", ";", "if", "(", "null", "!=", "geom", ")", "{", "geom", ".", "setSRID", "(", "srid", ")", ";", "getFeatureModel", "(", ")", ".", "setGeometry", "(", "feature", ",", "geom", ")", ";", "}", "}" ]
Enforces the correct srid on incoming features. @param feature object to enforce srid on @throws LayerException problem getting or setting srid
[ "Enforces", "the", "correct", "srid", "on", "incoming", "features", "." ]
904b7d7deed1350d28955589098dd1e0a786d76e
https://github.com/geomajas/geomajas-project-server/blob/904b7d7deed1350d28955589098dd1e0a786d76e/plugin/layer-hibernate/hibernate/src/main/java/org/geomajas/layer/hibernate/HibernateLayer.java#L467-L473
train
geomajas/geomajas-project-server
plugin/layer-hibernate/hibernate/src/main/java/org/geomajas/layer/hibernate/HibernateLayer.java
HibernateLayer.getBoundsLocal
private Envelope getBoundsLocal(Filter filter) throws LayerException { try { Session session = getSessionFactory().getCurrentSession(); Criteria criteria = session.createCriteria(getFeatureInfo().getDataSourceName()); CriteriaVisitor visitor = new CriteriaVisitor((HibernateFeatureModel) getFeatureModel(), dateFormat); Criterion c = (Criterion) filter.accept(visitor, criteria); if (c != null) { criteria.add(c); } criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); List<?> features = criteria.list(); Envelope bounds = new Envelope(); for (Object f : features) { Envelope geomBounds = getFeatureModel().getGeometry(f).getEnvelopeInternal(); if (!geomBounds.isNull()) { bounds.expandToInclude(geomBounds); } } return bounds; } catch (HibernateException he) { throw new HibernateLayerException(he, ExceptionCode.HIBERNATE_LOAD_FILTER_FAIL, getFeatureInfo() .getDataSourceName(), filter.toString()); } }
java
private Envelope getBoundsLocal(Filter filter) throws LayerException { try { Session session = getSessionFactory().getCurrentSession(); Criteria criteria = session.createCriteria(getFeatureInfo().getDataSourceName()); CriteriaVisitor visitor = new CriteriaVisitor((HibernateFeatureModel) getFeatureModel(), dateFormat); Criterion c = (Criterion) filter.accept(visitor, criteria); if (c != null) { criteria.add(c); } criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); List<?> features = criteria.list(); Envelope bounds = new Envelope(); for (Object f : features) { Envelope geomBounds = getFeatureModel().getGeometry(f).getEnvelopeInternal(); if (!geomBounds.isNull()) { bounds.expandToInclude(geomBounds); } } return bounds; } catch (HibernateException he) { throw new HibernateLayerException(he, ExceptionCode.HIBERNATE_LOAD_FILTER_FAIL, getFeatureInfo() .getDataSourceName(), filter.toString()); } }
[ "private", "Envelope", "getBoundsLocal", "(", "Filter", "filter", ")", "throws", "LayerException", "{", "try", "{", "Session", "session", "=", "getSessionFactory", "(", ")", ".", "getCurrentSession", "(", ")", ";", "Criteria", "criteria", "=", "session", ".", "createCriteria", "(", "getFeatureInfo", "(", ")", ".", "getDataSourceName", "(", ")", ")", ";", "CriteriaVisitor", "visitor", "=", "new", "CriteriaVisitor", "(", "(", "HibernateFeatureModel", ")", "getFeatureModel", "(", ")", ",", "dateFormat", ")", ";", "Criterion", "c", "=", "(", "Criterion", ")", "filter", ".", "accept", "(", "visitor", ",", "criteria", ")", ";", "if", "(", "c", "!=", "null", ")", "{", "criteria", ".", "add", "(", "c", ")", ";", "}", "criteria", ".", "setResultTransformer", "(", "Criteria", ".", "DISTINCT_ROOT_ENTITY", ")", ";", "List", "<", "?", ">", "features", "=", "criteria", ".", "list", "(", ")", ";", "Envelope", "bounds", "=", "new", "Envelope", "(", ")", ";", "for", "(", "Object", "f", ":", "features", ")", "{", "Envelope", "geomBounds", "=", "getFeatureModel", "(", ")", ".", "getGeometry", "(", "f", ")", ".", "getEnvelopeInternal", "(", ")", ";", "if", "(", "!", "geomBounds", ".", "isNull", "(", ")", ")", "{", "bounds", ".", "expandToInclude", "(", "geomBounds", ")", ";", "}", "}", "return", "bounds", ";", "}", "catch", "(", "HibernateException", "he", ")", "{", "throw", "new", "HibernateLayerException", "(", "he", ",", "ExceptionCode", ".", "HIBERNATE_LOAD_FILTER_FAIL", ",", "getFeatureInfo", "(", ")", ".", "getDataSourceName", "(", ")", ",", "filter", ".", "toString", "(", ")", ")", ";", "}", "}" ]
Bounds are calculated locally, can use any filter, but slower than native. @param filter filter which needs to be applied @return the bounds of the specified features @throws LayerException oops
[ "Bounds", "are", "calculated", "locally", "can", "use", "any", "filter", "but", "slower", "than", "native", "." ]
904b7d7deed1350d28955589098dd1e0a786d76e
https://github.com/geomajas/geomajas-project-server/blob/904b7d7deed1350d28955589098dd1e0a786d76e/plugin/layer-hibernate/hibernate/src/main/java/org/geomajas/layer/hibernate/HibernateLayer.java#L484-L507
train
geomajas/geomajas-project-server
impl/src/main/java/org/geomajas/spring/ThreadScopeContext.java
ThreadScopeContext.getBean
public Object getBean(String name) { Bean bean = beans.get(name); if (null == bean) { return null; } return bean.object; }
java
public Object getBean(String name) { Bean bean = beans.get(name); if (null == bean) { return null; } return bean.object; }
[ "public", "Object", "getBean", "(", "String", "name", ")", "{", "Bean", "bean", "=", "beans", ".", "get", "(", "name", ")", ";", "if", "(", "null", "==", "bean", ")", "{", "return", "null", ";", "}", "return", "bean", ".", "object", ";", "}" ]
Get a bean value from the context. @param name bean name @return bean value or null
[ "Get", "a", "bean", "value", "from", "the", "context", "." ]
904b7d7deed1350d28955589098dd1e0a786d76e
https://github.com/geomajas/geomajas-project-server/blob/904b7d7deed1350d28955589098dd1e0a786d76e/impl/src/main/java/org/geomajas/spring/ThreadScopeContext.java#L33-L39
train
geomajas/geomajas-project-server
impl/src/main/java/org/geomajas/spring/ThreadScopeContext.java
ThreadScopeContext.setBean
public void setBean(String name, Object object) { Bean bean = beans.get(name); if (null == bean) { bean = new Bean(); beans.put(name, bean); } bean.object = object; }
java
public void setBean(String name, Object object) { Bean bean = beans.get(name); if (null == bean) { bean = new Bean(); beans.put(name, bean); } bean.object = object; }
[ "public", "void", "setBean", "(", "String", "name", ",", "Object", "object", ")", "{", "Bean", "bean", "=", "beans", ".", "get", "(", "name", ")", ";", "if", "(", "null", "==", "bean", ")", "{", "bean", "=", "new", "Bean", "(", ")", ";", "beans", ".", "put", "(", "name", ",", "bean", ")", ";", "}", "bean", ".", "object", "=", "object", ";", "}" ]
Set a bean in the context. @param name bean name @param object bean value
[ "Set", "a", "bean", "in", "the", "context", "." ]
904b7d7deed1350d28955589098dd1e0a786d76e
https://github.com/geomajas/geomajas-project-server/blob/904b7d7deed1350d28955589098dd1e0a786d76e/impl/src/main/java/org/geomajas/spring/ThreadScopeContext.java#L47-L54
train
geomajas/geomajas-project-server
impl/src/main/java/org/geomajas/spring/ThreadScopeContext.java
ThreadScopeContext.remove
public Object remove(String name) { Bean bean = beans.get(name); if (null != bean) { beans.remove(name); bean.destructionCallback.run(); return bean.object; } return null; }
java
public Object remove(String name) { Bean bean = beans.get(name); if (null != bean) { beans.remove(name); bean.destructionCallback.run(); return bean.object; } return null; }
[ "public", "Object", "remove", "(", "String", "name", ")", "{", "Bean", "bean", "=", "beans", ".", "get", "(", "name", ")", ";", "if", "(", "null", "!=", "bean", ")", "{", "beans", ".", "remove", "(", "name", ")", ";", "bean", ".", "destructionCallback", ".", "run", "(", ")", ";", "return", "bean", ".", "object", ";", "}", "return", "null", ";", "}" ]
Remove a bean from the context, calling the destruction callback if any. @param name bean name @return previous value
[ "Remove", "a", "bean", "from", "the", "context", "calling", "the", "destruction", "callback", "if", "any", "." ]
904b7d7deed1350d28955589098dd1e0a786d76e
https://github.com/geomajas/geomajas-project-server/blob/904b7d7deed1350d28955589098dd1e0a786d76e/impl/src/main/java/org/geomajas/spring/ThreadScopeContext.java#L62-L70
train
geomajas/geomajas-project-server
impl/src/main/java/org/geomajas/spring/ThreadScopeContext.java
ThreadScopeContext.registerDestructionCallback
public void registerDestructionCallback(String name, Runnable callback) { Bean bean = beans.get(name); if (null == bean) { bean = new Bean(); beans.put(name, bean); } bean.destructionCallback = callback; }
java
public void registerDestructionCallback(String name, Runnable callback) { Bean bean = beans.get(name); if (null == bean) { bean = new Bean(); beans.put(name, bean); } bean.destructionCallback = callback; }
[ "public", "void", "registerDestructionCallback", "(", "String", "name", ",", "Runnable", "callback", ")", "{", "Bean", "bean", "=", "beans", ".", "get", "(", "name", ")", ";", "if", "(", "null", "==", "bean", ")", "{", "bean", "=", "new", "Bean", "(", ")", ";", "beans", ".", "put", "(", "name", ",", "bean", ")", ";", "}", "bean", ".", "destructionCallback", "=", "callback", ";", "}" ]
Register the given callback as to be executed after request completion. @param name The name of the bean. @param callback The callback of the bean to be executed for destruction.
[ "Register", "the", "given", "callback", "as", "to", "be", "executed", "after", "request", "completion", "." ]
904b7d7deed1350d28955589098dd1e0a786d76e
https://github.com/geomajas/geomajas-project-server/blob/904b7d7deed1350d28955589098dd1e0a786d76e/impl/src/main/java/org/geomajas/spring/ThreadScopeContext.java#L78-L85
train
geomajas/geomajas-project-server
impl/src/main/java/org/geomajas/spring/ThreadScopeContext.java
ThreadScopeContext.clear
public void clear() { for (Bean bean : beans.values()) { if (null != bean.destructionCallback) { bean.destructionCallback.run(); } } beans.clear(); }
java
public void clear() { for (Bean bean : beans.values()) { if (null != bean.destructionCallback) { bean.destructionCallback.run(); } } beans.clear(); }
[ "public", "void", "clear", "(", ")", "{", "for", "(", "Bean", "bean", ":", "beans", ".", "values", "(", ")", ")", "{", "if", "(", "null", "!=", "bean", ".", "destructionCallback", ")", "{", "bean", ".", "destructionCallback", ".", "run", "(", ")", ";", "}", "}", "beans", ".", "clear", "(", ")", ";", "}" ]
Clear all beans and call the destruction callback.
[ "Clear", "all", "beans", "and", "call", "the", "destruction", "callback", "." ]
904b7d7deed1350d28955589098dd1e0a786d76e
https://github.com/geomajas/geomajas-project-server/blob/904b7d7deed1350d28955589098dd1e0a786d76e/impl/src/main/java/org/geomajas/spring/ThreadScopeContext.java#L88-L95
train
geomajas/geomajas-project-server
plugin/layer-wms/wms/src/main/java/org/geomajas/layer/wms/mvc/WmsProxyController.java
WmsProxyController.parseLayerId
private String parseLayerId(HttpServletRequest request) { StringTokenizer tokenizer = new StringTokenizer(request.getRequestURI(), "/"); String token = ""; while (tokenizer.hasMoreTokens()) { token = tokenizer.nextToken(); } return token; }
java
private String parseLayerId(HttpServletRequest request) { StringTokenizer tokenizer = new StringTokenizer(request.getRequestURI(), "/"); String token = ""; while (tokenizer.hasMoreTokens()) { token = tokenizer.nextToken(); } return token; }
[ "private", "String", "parseLayerId", "(", "HttpServletRequest", "request", ")", "{", "StringTokenizer", "tokenizer", "=", "new", "StringTokenizer", "(", "request", ".", "getRequestURI", "(", ")", ",", "\"/\"", ")", ";", "String", "token", "=", "\"\"", ";", "while", "(", "tokenizer", ".", "hasMoreTokens", "(", ")", ")", "{", "token", "=", "tokenizer", ".", "nextToken", "(", ")", ";", "}", "return", "token", ";", "}" ]
Get the layer ID out of the request URL. @param request servlet request @return layer id
[ "Get", "the", "layer", "ID", "out", "of", "the", "request", "URL", "." ]
904b7d7deed1350d28955589098dd1e0a786d76e
https://github.com/geomajas/geomajas-project-server/blob/904b7d7deed1350d28955589098dd1e0a786d76e/plugin/layer-wms/wms/src/main/java/org/geomajas/layer/wms/mvc/WmsProxyController.java#L129-L136
train
geomajas/geomajas-project-server
plugin/layer-wms/wms/src/main/java/org/geomajas/layer/wms/mvc/WmsProxyController.java
WmsProxyController.getLayer
private WmsLayer getLayer(String layerId) { RasterLayer layer = configurationService.getRasterLayer(layerId); if (layer instanceof WmsLayer) { return (WmsLayer) layer; } return null; }
java
private WmsLayer getLayer(String layerId) { RasterLayer layer = configurationService.getRasterLayer(layerId); if (layer instanceof WmsLayer) { return (WmsLayer) layer; } return null; }
[ "private", "WmsLayer", "getLayer", "(", "String", "layerId", ")", "{", "RasterLayer", "layer", "=", "configurationService", ".", "getRasterLayer", "(", "layerId", ")", ";", "if", "(", "layer", "instanceof", "WmsLayer", ")", "{", "return", "(", "WmsLayer", ")", "layer", ";", "}", "return", "null", ";", "}" ]
Given a layer ID, search for the WMS layer. @param layerId layer id @return WMS layer or null if layer is not a WMS layer
[ "Given", "a", "layer", "ID", "search", "for", "the", "WMS", "layer", "." ]
904b7d7deed1350d28955589098dd1e0a786d76e
https://github.com/geomajas/geomajas-project-server/blob/904b7d7deed1350d28955589098dd1e0a786d76e/plugin/layer-wms/wms/src/main/java/org/geomajas/layer/wms/mvc/WmsProxyController.java#L144-L150
train
geomajas/geomajas-project-server
plugin/layer-wms/wms/src/main/java/org/geomajas/layer/wms/mvc/WmsProxyController.java
WmsProxyController.createErrorImage
private byte[] createErrorImage(int width, int height, Exception e) throws IOException { String error = e.getMessage(); if (null == error) { Writer result = new StringWriter(); PrintWriter printWriter = new PrintWriter(result); e.printStackTrace(printWriter); error = result.toString(); } BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR); Graphics2D g = (Graphics2D) image.getGraphics(); g.setColor(Color.RED); g.drawString(error, ERROR_MESSAGE_X, height / 2); ByteArrayOutputStream out = new ByteArrayOutputStream(); ImageIO.write(image, "PNG", out); out.flush(); byte[] result = out.toByteArray(); out.close(); return result; }
java
private byte[] createErrorImage(int width, int height, Exception e) throws IOException { String error = e.getMessage(); if (null == error) { Writer result = new StringWriter(); PrintWriter printWriter = new PrintWriter(result); e.printStackTrace(printWriter); error = result.toString(); } BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR); Graphics2D g = (Graphics2D) image.getGraphics(); g.setColor(Color.RED); g.drawString(error, ERROR_MESSAGE_X, height / 2); ByteArrayOutputStream out = new ByteArrayOutputStream(); ImageIO.write(image, "PNG", out); out.flush(); byte[] result = out.toByteArray(); out.close(); return result; }
[ "private", "byte", "[", "]", "createErrorImage", "(", "int", "width", ",", "int", "height", ",", "Exception", "e", ")", "throws", "IOException", "{", "String", "error", "=", "e", ".", "getMessage", "(", ")", ";", "if", "(", "null", "==", "error", ")", "{", "Writer", "result", "=", "new", "StringWriter", "(", ")", ";", "PrintWriter", "printWriter", "=", "new", "PrintWriter", "(", "result", ")", ";", "e", ".", "printStackTrace", "(", "printWriter", ")", ";", "error", "=", "result", ".", "toString", "(", ")", ";", "}", "BufferedImage", "image", "=", "new", "BufferedImage", "(", "width", ",", "height", ",", "BufferedImage", ".", "TYPE_4BYTE_ABGR", ")", ";", "Graphics2D", "g", "=", "(", "Graphics2D", ")", "image", ".", "getGraphics", "(", ")", ";", "g", ".", "setColor", "(", "Color", ".", "RED", ")", ";", "g", ".", "drawString", "(", "error", ",", "ERROR_MESSAGE_X", ",", "height", "/", "2", ")", ";", "ByteArrayOutputStream", "out", "=", "new", "ByteArrayOutputStream", "(", ")", ";", "ImageIO", ".", "write", "(", "image", ",", "\"PNG\"", ",", "out", ")", ";", "out", ".", "flush", "(", ")", ";", "byte", "[", "]", "result", "=", "out", ".", "toByteArray", "(", ")", ";", "out", ".", "close", "(", ")", ";", "return", "result", ";", "}" ]
Create an error image should an error occur while fetching a WMS map. @param width image width @param height image height @param e exception @return error image @throws java.io.IOException oops
[ "Create", "an", "error", "image", "should", "an", "error", "occur", "while", "fetching", "a", "WMS", "map", "." ]
904b7d7deed1350d28955589098dd1e0a786d76e
https://github.com/geomajas/geomajas-project-server/blob/904b7d7deed1350d28955589098dd1e0a786d76e/plugin/layer-wms/wms/src/main/java/org/geomajas/layer/wms/mvc/WmsProxyController.java#L161-L183
train
foundation-runtime/logging
logging-log4j/src/main/java/com/cisco/oss/foundation/logging/LoggingHelper.java
LoggingHelper.formatConnectionEstablishmentMessage
public static String formatConnectionEstablishmentMessage(final String connectionName, final String host, final String connectionReason) { return CON_ESTABLISHMENT_FORMAT.format(new Object[] { connectionName, host, connectionReason }); }
java
public static String formatConnectionEstablishmentMessage(final String connectionName, final String host, final String connectionReason) { return CON_ESTABLISHMENT_FORMAT.format(new Object[] { connectionName, host, connectionReason }); }
[ "public", "static", "String", "formatConnectionEstablishmentMessage", "(", "final", "String", "connectionName", ",", "final", "String", "host", ",", "final", "String", "connectionReason", ")", "{", "return", "CON_ESTABLISHMENT_FORMAT", ".", "format", "(", "new", "Object", "[", "]", "{", "connectionName", ",", "host", ",", "connectionReason", "}", ")", ";", "}" ]
Helper method for formatting connection establishment messages. @param connectionName The name of the connection @param host The remote host @param connectionReason The reason for establishing the connection @return A formatted message in the format: "[&lt;connectionName&gt;] remote host[&lt;host&gt;] &lt;connectionReason&gt;" <br/> e.g. [con1] remote host[123.123.123.123] connection to ECMG.
[ "Helper", "method", "for", "formatting", "connection", "establishment", "messages", "." ]
cd0a07b3c5b458ecf90ab92a1e0c72a067f5cbd6
https://github.com/foundation-runtime/logging/blob/cd0a07b3c5b458ecf90ab92a1e0c72a067f5cbd6/logging-log4j/src/main/java/com/cisco/oss/foundation/logging/LoggingHelper.java#L465-L467
train
foundation-runtime/logging
logging-log4j/src/main/java/com/cisco/oss/foundation/logging/LoggingHelper.java
LoggingHelper.formatConnectionTerminationMessage
public static String formatConnectionTerminationMessage(final String connectionName, final String host, final String connectionReason, final String terminationReason) { return CON_TERMINATION_FORMAT.format(new Object[] { connectionName, host, connectionReason, terminationReason }); }
java
public static String formatConnectionTerminationMessage(final String connectionName, final String host, final String connectionReason, final String terminationReason) { return CON_TERMINATION_FORMAT.format(new Object[] { connectionName, host, connectionReason, terminationReason }); }
[ "public", "static", "String", "formatConnectionTerminationMessage", "(", "final", "String", "connectionName", ",", "final", "String", "host", ",", "final", "String", "connectionReason", ",", "final", "String", "terminationReason", ")", "{", "return", "CON_TERMINATION_FORMAT", ".", "format", "(", "new", "Object", "[", "]", "{", "connectionName", ",", "host", ",", "connectionReason", ",", "terminationReason", "}", ")", ";", "}" ]
Helper method for formatting connection termination messages. @param connectionName The name of the connection @param host The remote host @param connectionReason The reason for establishing the connection @param terminationReason The reason for terminating the connection @return A formatted message in the format: "[&lt;connectionName&gt;] remote host[&lt;host&gt;] &lt;connectionReason&gt; - &lt;terminationReason&gt;" <br/> e.g. [con1] remote host[123.123.123.123] connection to ECMG - terminated by remote host.
[ "Helper", "method", "for", "formatting", "connection", "termination", "messages", "." ]
cd0a07b3c5b458ecf90ab92a1e0c72a067f5cbd6
https://github.com/foundation-runtime/logging/blob/cd0a07b3c5b458ecf90ab92a1e0c72a067f5cbd6/logging-log4j/src/main/java/com/cisco/oss/foundation/logging/LoggingHelper.java#L486-L488
train
kuali/ojb-1.0.4
src/java/org/apache/ojb/broker/metadata/JdbcMetadataUtils.java
JdbcMetadataUtils.findPlatformFor
public String findPlatformFor(String jdbcSubProtocol, String jdbcDriver) { String platform = (String)jdbcSubProtocolToPlatform.get(jdbcSubProtocol); if (platform == null) { platform = (String)jdbcDriverToPlatform.get(jdbcDriver); } return platform; }
java
public String findPlatformFor(String jdbcSubProtocol, String jdbcDriver) { String platform = (String)jdbcSubProtocolToPlatform.get(jdbcSubProtocol); if (platform == null) { platform = (String)jdbcDriverToPlatform.get(jdbcDriver); } return platform; }
[ "public", "String", "findPlatformFor", "(", "String", "jdbcSubProtocol", ",", "String", "jdbcDriver", ")", "{", "String", "platform", "=", "(", "String", ")", "jdbcSubProtocolToPlatform", ".", "get", "(", "jdbcSubProtocol", ")", ";", "if", "(", "platform", "==", "null", ")", "{", "platform", "=", "(", "String", ")", "jdbcDriverToPlatform", ".", "get", "(", "jdbcDriver", ")", ";", "}", "return", "platform", ";", "}" ]
Derives the OJB platform to use for a database that is connected via a url using the specified subprotocol, and where the specified jdbc driver is used. @param jdbcSubProtocol The JDBC subprotocol used to connect to the database @param jdbcDriver The JDBC driver used to connect to the database @return The platform identifier or <code>null</code> if no platform could be found
[ "Derives", "the", "OJB", "platform", "to", "use", "for", "a", "database", "that", "is", "connected", "via", "a", "url", "using", "the", "specified", "subprotocol", "and", "where", "the", "specified", "jdbc", "driver", "is", "used", "." ]
9a544372f67ce965f662cdc71609dd03683c8f04
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/metadata/JdbcMetadataUtils.java#L391-L400
train
Axway/Grapes
server/src/main/java/org/axway/grapes/server/webapp/DataValidator.java
DataValidator.validate
public static void validate(final License license) { // A license should have a name if(license.getName() == null || license.getName().isEmpty()){ throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST) .entity("License name should not be empty!") .build()); } // A license should have a long name if(license.getLongName() == null || license.getLongName().isEmpty()){ throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST) .entity("License long name should not be empty!") .build()); } // If there is a regexp, it should compile if(license.getRegexp() != null && !license.getRegexp().isEmpty()){ try{ Pattern.compile(license.getRegexp()); } catch (PatternSyntaxException e){ throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST) .entity("License regexp does not compile!").build()); } Pattern regex = Pattern.compile("[&%//]"); if(regex.matcher(license.getRegexp()).find()){ throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST) .entity("License regexp does not compile!").build()); } } }
java
public static void validate(final License license) { // A license should have a name if(license.getName() == null || license.getName().isEmpty()){ throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST) .entity("License name should not be empty!") .build()); } // A license should have a long name if(license.getLongName() == null || license.getLongName().isEmpty()){ throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST) .entity("License long name should not be empty!") .build()); } // If there is a regexp, it should compile if(license.getRegexp() != null && !license.getRegexp().isEmpty()){ try{ Pattern.compile(license.getRegexp()); } catch (PatternSyntaxException e){ throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST) .entity("License regexp does not compile!").build()); } Pattern regex = Pattern.compile("[&%//]"); if(regex.matcher(license.getRegexp()).find()){ throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST) .entity("License regexp does not compile!").build()); } } }
[ "public", "static", "void", "validate", "(", "final", "License", "license", ")", "{", "// A license should have a name", "if", "(", "license", ".", "getName", "(", ")", "==", "null", "||", "license", ".", "getName", "(", ")", ".", "isEmpty", "(", ")", ")", "{", "throw", "new", "WebApplicationException", "(", "Response", ".", "status", "(", "Response", ".", "Status", ".", "BAD_REQUEST", ")", ".", "entity", "(", "\"License name should not be empty!\"", ")", ".", "build", "(", ")", ")", ";", "}", "// A license should have a long name", "if", "(", "license", ".", "getLongName", "(", ")", "==", "null", "||", "license", ".", "getLongName", "(", ")", ".", "isEmpty", "(", ")", ")", "{", "throw", "new", "WebApplicationException", "(", "Response", ".", "status", "(", "Response", ".", "Status", ".", "BAD_REQUEST", ")", ".", "entity", "(", "\"License long name should not be empty!\"", ")", ".", "build", "(", ")", ")", ";", "}", "// If there is a regexp, it should compile", "if", "(", "license", ".", "getRegexp", "(", ")", "!=", "null", "&&", "!", "license", ".", "getRegexp", "(", ")", ".", "isEmpty", "(", ")", ")", "{", "try", "{", "Pattern", ".", "compile", "(", "license", ".", "getRegexp", "(", ")", ")", ";", "}", "catch", "(", "PatternSyntaxException", "e", ")", "{", "throw", "new", "WebApplicationException", "(", "Response", ".", "status", "(", "Response", ".", "Status", ".", "BAD_REQUEST", ")", ".", "entity", "(", "\"License regexp does not compile!\"", ")", ".", "build", "(", ")", ")", ";", "}", "Pattern", "regex", "=", "Pattern", ".", "compile", "(", "\"[&%//]\"", ")", ";", "if", "(", "regex", ".", "matcher", "(", "license", ".", "getRegexp", "(", ")", ")", ".", "find", "(", ")", ")", "{", "throw", "new", "WebApplicationException", "(", "Response", ".", "status", "(", "Response", ".", "Status", ".", "BAD_REQUEST", ")", ".", "entity", "(", "\"License regexp does not compile!\"", ")", ".", "build", "(", ")", ")", ";", "}", "}", "}" ]
Checks if the provided license is valid and could be stored into the database @param license the license to test @throws WebApplicationException if the data is corrupted
[ "Checks", "if", "the", "provided", "license", "is", "valid", "and", "could", "be", "stored", "into", "the", "database" ]
ce9cc73d85f83eaa5fbc991abb593915a8c8374e
https://github.com/Axway/Grapes/blob/ce9cc73d85f83eaa5fbc991abb593915a8c8374e/server/src/main/java/org/axway/grapes/server/webapp/DataValidator.java#L88-L123
train
Axway/Grapes
server/src/main/java/org/axway/grapes/server/webapp/DataValidator.java
DataValidator.validate
public static void validate(final Module module) { if (null == module) { throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST) .entity("Module cannot be null!") .build()); } if(module.getName() == null || module.getName().isEmpty()){ throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST) .entity("Module name cannot be null or empty!") .build()); } if(module.getVersion()== null || module.getVersion().isEmpty()){ throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST) .entity("Module version cannot be null or empty!") .build()); } // Check artifacts for(final Artifact artifact: DataUtils.getAllArtifacts(module)){ validate(artifact); } // Check dependencies for(final Dependency dependency: DataUtils.getAllDependencies(module)){ validate(dependency.getTarget()); } }
java
public static void validate(final Module module) { if (null == module) { throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST) .entity("Module cannot be null!") .build()); } if(module.getName() == null || module.getName().isEmpty()){ throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST) .entity("Module name cannot be null or empty!") .build()); } if(module.getVersion()== null || module.getVersion().isEmpty()){ throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST) .entity("Module version cannot be null or empty!") .build()); } // Check artifacts for(final Artifact artifact: DataUtils.getAllArtifacts(module)){ validate(artifact); } // Check dependencies for(final Dependency dependency: DataUtils.getAllDependencies(module)){ validate(dependency.getTarget()); } }
[ "public", "static", "void", "validate", "(", "final", "Module", "module", ")", "{", "if", "(", "null", "==", "module", ")", "{", "throw", "new", "WebApplicationException", "(", "Response", ".", "status", "(", "Response", ".", "Status", ".", "BAD_REQUEST", ")", ".", "entity", "(", "\"Module cannot be null!\"", ")", ".", "build", "(", ")", ")", ";", "}", "if", "(", "module", ".", "getName", "(", ")", "==", "null", "||", "module", ".", "getName", "(", ")", ".", "isEmpty", "(", ")", ")", "{", "throw", "new", "WebApplicationException", "(", "Response", ".", "status", "(", "Response", ".", "Status", ".", "BAD_REQUEST", ")", ".", "entity", "(", "\"Module name cannot be null or empty!\"", ")", ".", "build", "(", ")", ")", ";", "}", "if", "(", "module", ".", "getVersion", "(", ")", "==", "null", "||", "module", ".", "getVersion", "(", ")", ".", "isEmpty", "(", ")", ")", "{", "throw", "new", "WebApplicationException", "(", "Response", ".", "status", "(", "Response", ".", "Status", ".", "BAD_REQUEST", ")", ".", "entity", "(", "\"Module version cannot be null or empty!\"", ")", ".", "build", "(", ")", ")", ";", "}", "// Check artifacts", "for", "(", "final", "Artifact", "artifact", ":", "DataUtils", ".", "getAllArtifacts", "(", "module", ")", ")", "{", "validate", "(", "artifact", ")", ";", "}", "// Check dependencies", "for", "(", "final", "Dependency", "dependency", ":", "DataUtils", ".", "getAllDependencies", "(", "module", ")", ")", "{", "validate", "(", "dependency", ".", "getTarget", "(", ")", ")", ";", "}", "}" ]
Checks if the provided module is valid and could be stored into the database @param module the module to test @throws WebApplicationException if the data is corrupted
[ "Checks", "if", "the", "provided", "module", "is", "valid", "and", "could", "be", "stored", "into", "the", "database" ]
ce9cc73d85f83eaa5fbc991abb593915a8c8374e
https://github.com/Axway/Grapes/blob/ce9cc73d85f83eaa5fbc991abb593915a8c8374e/server/src/main/java/org/axway/grapes/server/webapp/DataValidator.java#L131-L159
train
Axway/Grapes
server/src/main/java/org/axway/grapes/server/webapp/DataValidator.java
DataValidator.validate
public static void validate(final Organization organization) { if(organization.getName() == null || organization.getName().isEmpty()){ throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST) .entity("Organization name cannot be null or empty!") .build()); } }
java
public static void validate(final Organization organization) { if(organization.getName() == null || organization.getName().isEmpty()){ throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST) .entity("Organization name cannot be null or empty!") .build()); } }
[ "public", "static", "void", "validate", "(", "final", "Organization", "organization", ")", "{", "if", "(", "organization", ".", "getName", "(", ")", "==", "null", "||", "organization", ".", "getName", "(", ")", ".", "isEmpty", "(", ")", ")", "{", "throw", "new", "WebApplicationException", "(", "Response", ".", "status", "(", "Response", ".", "Status", ".", "BAD_REQUEST", ")", ".", "entity", "(", "\"Organization name cannot be null or empty!\"", ")", ".", "build", "(", ")", ")", ";", "}", "}" ]
Checks if the provided organization is valid and could be stored into the database @param organization Organization @throws WebApplicationException if the data is corrupted
[ "Checks", "if", "the", "provided", "organization", "is", "valid", "and", "could", "be", "stored", "into", "the", "database" ]
ce9cc73d85f83eaa5fbc991abb593915a8c8374e
https://github.com/Axway/Grapes/blob/ce9cc73d85f83eaa5fbc991abb593915a8c8374e/server/src/main/java/org/axway/grapes/server/webapp/DataValidator.java#L167-L174
train
Axway/Grapes
server/src/main/java/org/axway/grapes/server/webapp/DataValidator.java
DataValidator.validate
public static void validate(final ArtifactQuery artifactQuery) { final Pattern invalidChars = Pattern.compile("[^A-Fa-f0-9]"); if(artifactQuery.getUser() == null || artifactQuery.getUser().isEmpty()){ throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST) .entity("Mandatory field [user] missing") .build()); } if( artifactQuery.getStage() != 0 && artifactQuery.getStage() !=1 ){ throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST) .entity("Invalid [stage] value (supported 0 | 1)") .build()); } if(artifactQuery.getName() == null || artifactQuery.getName().isEmpty()){ throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST) .entity("Mandatory field [name] missing, it should be the file name") .build()); } if(artifactQuery.getSha256() == null || artifactQuery.getSha256().isEmpty()){ throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST) .entity("Mandatory field [sha256] missing") .build()); } if(artifactQuery.getSha256().length() < 64 || invalidChars.matcher(artifactQuery.getSha256()).find()){ throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST) .entity("Invalid file checksum value") .build()); } if(artifactQuery.getType() == null || artifactQuery.getType().isEmpty()){ throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST) .entity("Mandatory field [type] missing") .build()); } }
java
public static void validate(final ArtifactQuery artifactQuery) { final Pattern invalidChars = Pattern.compile("[^A-Fa-f0-9]"); if(artifactQuery.getUser() == null || artifactQuery.getUser().isEmpty()){ throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST) .entity("Mandatory field [user] missing") .build()); } if( artifactQuery.getStage() != 0 && artifactQuery.getStage() !=1 ){ throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST) .entity("Invalid [stage] value (supported 0 | 1)") .build()); } if(artifactQuery.getName() == null || artifactQuery.getName().isEmpty()){ throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST) .entity("Mandatory field [name] missing, it should be the file name") .build()); } if(artifactQuery.getSha256() == null || artifactQuery.getSha256().isEmpty()){ throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST) .entity("Mandatory field [sha256] missing") .build()); } if(artifactQuery.getSha256().length() < 64 || invalidChars.matcher(artifactQuery.getSha256()).find()){ throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST) .entity("Invalid file checksum value") .build()); } if(artifactQuery.getType() == null || artifactQuery.getType().isEmpty()){ throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST) .entity("Mandatory field [type] missing") .build()); } }
[ "public", "static", "void", "validate", "(", "final", "ArtifactQuery", "artifactQuery", ")", "{", "final", "Pattern", "invalidChars", "=", "Pattern", ".", "compile", "(", "\"[^A-Fa-f0-9]\"", ")", ";", "if", "(", "artifactQuery", ".", "getUser", "(", ")", "==", "null", "||", "artifactQuery", ".", "getUser", "(", ")", ".", "isEmpty", "(", ")", ")", "{", "throw", "new", "WebApplicationException", "(", "Response", ".", "status", "(", "Response", ".", "Status", ".", "BAD_REQUEST", ")", ".", "entity", "(", "\"Mandatory field [user] missing\"", ")", ".", "build", "(", ")", ")", ";", "}", "if", "(", "artifactQuery", ".", "getStage", "(", ")", "!=", "0", "&&", "artifactQuery", ".", "getStage", "(", ")", "!=", "1", ")", "{", "throw", "new", "WebApplicationException", "(", "Response", ".", "status", "(", "Response", ".", "Status", ".", "BAD_REQUEST", ")", ".", "entity", "(", "\"Invalid [stage] value (supported 0 | 1)\"", ")", ".", "build", "(", ")", ")", ";", "}", "if", "(", "artifactQuery", ".", "getName", "(", ")", "==", "null", "||", "artifactQuery", ".", "getName", "(", ")", ".", "isEmpty", "(", ")", ")", "{", "throw", "new", "WebApplicationException", "(", "Response", ".", "status", "(", "Response", ".", "Status", ".", "BAD_REQUEST", ")", ".", "entity", "(", "\"Mandatory field [name] missing, it should be the file name\"", ")", ".", "build", "(", ")", ")", ";", "}", "if", "(", "artifactQuery", ".", "getSha256", "(", ")", "==", "null", "||", "artifactQuery", ".", "getSha256", "(", ")", ".", "isEmpty", "(", ")", ")", "{", "throw", "new", "WebApplicationException", "(", "Response", ".", "status", "(", "Response", ".", "Status", ".", "BAD_REQUEST", ")", ".", "entity", "(", "\"Mandatory field [sha256] missing\"", ")", ".", "build", "(", ")", ")", ";", "}", "if", "(", "artifactQuery", ".", "getSha256", "(", ")", ".", "length", "(", ")", "<", "64", "||", "invalidChars", ".", "matcher", "(", "artifactQuery", ".", "getSha256", "(", ")", ")", ".", "find", "(", ")", ")", "{", "throw", "new", "WebApplicationException", "(", "Response", ".", "status", "(", "Response", ".", "Status", ".", "BAD_REQUEST", ")", ".", "entity", "(", "\"Invalid file checksum value\"", ")", ".", "build", "(", ")", ")", ";", "}", "if", "(", "artifactQuery", ".", "getType", "(", ")", "==", "null", "||", "artifactQuery", ".", "getType", "(", ")", ".", "isEmpty", "(", ")", ")", "{", "throw", "new", "WebApplicationException", "(", "Response", ".", "status", "(", "Response", ".", "Status", ".", "BAD_REQUEST", ")", ".", "entity", "(", "\"Mandatory field [type] missing\"", ")", ".", "build", "(", ")", ")", ";", "}", "}" ]
Checks if the provided artifactQuery is valid @param artifactQuery ArtifactQuery @throws WebApplicationException if the data is corrupted
[ "Checks", "if", "the", "provided", "artifactQuery", "is", "valid" ]
ce9cc73d85f83eaa5fbc991abb593915a8c8374e
https://github.com/Axway/Grapes/blob/ce9cc73d85f83eaa5fbc991abb593915a8c8374e/server/src/main/java/org/axway/grapes/server/webapp/DataValidator.java#L182-L218
train
kuali/ojb-1.0.4
src/java/org/apache/ojb/broker/util/sequence/SequenceManagerNextValImpl.java
SequenceManagerNextValImpl.getUniqueLong
protected long getUniqueLong(FieldDescriptor field) throws SequenceManagerException { long result; // lookup sequence name String sequenceName = calculateSequenceName(field); try { result = buildNextSequence(field.getClassDescriptor(), sequenceName); } catch (Throwable e) { // maybe the sequence was not created try { log.info("Create DB sequence key '"+sequenceName+"'"); createSequence(field.getClassDescriptor(), sequenceName); } catch (Exception e1) { throw new SequenceManagerException( SystemUtils.LINE_SEPARATOR + "Could not grab next id, failed with " + SystemUtils.LINE_SEPARATOR + e.getMessage() + SystemUtils.LINE_SEPARATOR + "Creation of new sequence failed with " + SystemUtils.LINE_SEPARATOR + e1.getMessage() + SystemUtils.LINE_SEPARATOR , e1); } try { result = buildNextSequence(field.getClassDescriptor(), sequenceName); } catch (Throwable e1) { throw new SequenceManagerException("Could not grab next id, sequence seems to exist", e); } } return result; }
java
protected long getUniqueLong(FieldDescriptor field) throws SequenceManagerException { long result; // lookup sequence name String sequenceName = calculateSequenceName(field); try { result = buildNextSequence(field.getClassDescriptor(), sequenceName); } catch (Throwable e) { // maybe the sequence was not created try { log.info("Create DB sequence key '"+sequenceName+"'"); createSequence(field.getClassDescriptor(), sequenceName); } catch (Exception e1) { throw new SequenceManagerException( SystemUtils.LINE_SEPARATOR + "Could not grab next id, failed with " + SystemUtils.LINE_SEPARATOR + e.getMessage() + SystemUtils.LINE_SEPARATOR + "Creation of new sequence failed with " + SystemUtils.LINE_SEPARATOR + e1.getMessage() + SystemUtils.LINE_SEPARATOR , e1); } try { result = buildNextSequence(field.getClassDescriptor(), sequenceName); } catch (Throwable e1) { throw new SequenceManagerException("Could not grab next id, sequence seems to exist", e); } } return result; }
[ "protected", "long", "getUniqueLong", "(", "FieldDescriptor", "field", ")", "throws", "SequenceManagerException", "{", "long", "result", ";", "// lookup sequence name\r", "String", "sequenceName", "=", "calculateSequenceName", "(", "field", ")", ";", "try", "{", "result", "=", "buildNextSequence", "(", "field", ".", "getClassDescriptor", "(", ")", ",", "sequenceName", ")", ";", "}", "catch", "(", "Throwable", "e", ")", "{", "// maybe the sequence was not created\r", "try", "{", "log", ".", "info", "(", "\"Create DB sequence key '\"", "+", "sequenceName", "+", "\"'\"", ")", ";", "createSequence", "(", "field", ".", "getClassDescriptor", "(", ")", ",", "sequenceName", ")", ";", "}", "catch", "(", "Exception", "e1", ")", "{", "throw", "new", "SequenceManagerException", "(", "SystemUtils", ".", "LINE_SEPARATOR", "+", "\"Could not grab next id, failed with \"", "+", "SystemUtils", ".", "LINE_SEPARATOR", "+", "e", ".", "getMessage", "(", ")", "+", "SystemUtils", ".", "LINE_SEPARATOR", "+", "\"Creation of new sequence failed with \"", "+", "SystemUtils", ".", "LINE_SEPARATOR", "+", "e1", ".", "getMessage", "(", ")", "+", "SystemUtils", ".", "LINE_SEPARATOR", ",", "e1", ")", ";", "}", "try", "{", "result", "=", "buildNextSequence", "(", "field", ".", "getClassDescriptor", "(", ")", ",", "sequenceName", ")", ";", "}", "catch", "(", "Throwable", "e1", ")", "{", "throw", "new", "SequenceManagerException", "(", "\"Could not grab next id, sequence seems to exist\"", ",", "e", ")", ";", "}", "}", "return", "result", ";", "}" ]
returns a unique long value for class clazz and field fieldName. the returned number is unique accross all tables in the extent of clazz.
[ "returns", "a", "unique", "long", "value", "for", "class", "clazz", "and", "field", "fieldName", ".", "the", "returned", "number", "is", "unique", "accross", "all", "tables", "in", "the", "extent", "of", "clazz", "." ]
9a544372f67ce965f662cdc71609dd03683c8f04
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/util/sequence/SequenceManagerNextValImpl.java#L118-L155
train
kuali/ojb-1.0.4
src/jdori/org/apache/ojb/jdori/sql/OjbExtent.java
OjbExtent.provideStateManagers
protected Collection provideStateManagers(Collection pojos) { PersistenceCapable pc; int [] fieldNums; Iterator iter = pojos.iterator(); Collection result = new ArrayList(); while (iter.hasNext()) { // obtain a StateManager pc = (PersistenceCapable) iter.next(); Identity oid = new Identity(pc, broker); StateManagerInternal smi = pmi.getStateManager(oid, pc.getClass()); // fetch attributes into StateManager JDOClass jdoClass = Helper.getJDOClass(pc.getClass()); fieldNums = jdoClass.getManagedFieldNumbers(); FieldManager fm = new OjbFieldManager(pc, broker); smi.replaceFields(fieldNums, fm); smi.retrieve(); // get JDO PersistencecCapable instance from SM and add it to result collection Object instance = smi.getObject(); result.add(instance); } return result; }
java
protected Collection provideStateManagers(Collection pojos) { PersistenceCapable pc; int [] fieldNums; Iterator iter = pojos.iterator(); Collection result = new ArrayList(); while (iter.hasNext()) { // obtain a StateManager pc = (PersistenceCapable) iter.next(); Identity oid = new Identity(pc, broker); StateManagerInternal smi = pmi.getStateManager(oid, pc.getClass()); // fetch attributes into StateManager JDOClass jdoClass = Helper.getJDOClass(pc.getClass()); fieldNums = jdoClass.getManagedFieldNumbers(); FieldManager fm = new OjbFieldManager(pc, broker); smi.replaceFields(fieldNums, fm); smi.retrieve(); // get JDO PersistencecCapable instance from SM and add it to result collection Object instance = smi.getObject(); result.add(instance); } return result; }
[ "protected", "Collection", "provideStateManagers", "(", "Collection", "pojos", ")", "{", "PersistenceCapable", "pc", ";", "int", "[", "]", "fieldNums", ";", "Iterator", "iter", "=", "pojos", ".", "iterator", "(", ")", ";", "Collection", "result", "=", "new", "ArrayList", "(", ")", ";", "while", "(", "iter", ".", "hasNext", "(", ")", ")", "{", "// obtain a StateManager\r", "pc", "=", "(", "PersistenceCapable", ")", "iter", ".", "next", "(", ")", ";", "Identity", "oid", "=", "new", "Identity", "(", "pc", ",", "broker", ")", ";", "StateManagerInternal", "smi", "=", "pmi", ".", "getStateManager", "(", "oid", ",", "pc", ".", "getClass", "(", ")", ")", ";", "// fetch attributes into StateManager\r", "JDOClass", "jdoClass", "=", "Helper", ".", "getJDOClass", "(", "pc", ".", "getClass", "(", ")", ")", ";", "fieldNums", "=", "jdoClass", ".", "getManagedFieldNumbers", "(", ")", ";", "FieldManager", "fm", "=", "new", "OjbFieldManager", "(", "pc", ",", "broker", ")", ";", "smi", ".", "replaceFields", "(", "fieldNums", ",", "fm", ")", ";", "smi", ".", "retrieve", "(", ")", ";", "// get JDO PersistencecCapable instance from SM and add it to result collection\r", "Object", "instance", "=", "smi", ".", "getObject", "(", ")", ";", "result", ".", "add", "(", "instance", ")", ";", "}", "return", "result", ";", "}" ]
This methods enhances the objects loaded by a broker query with a JDO StateManager an brings them under JDO control. @param pojos the OJB pojos as obtained by the broker @return the collection of JDO PersistenceCapable instances
[ "This", "methods", "enhances", "the", "objects", "loaded", "by", "a", "broker", "query", "with", "a", "JDO", "StateManager", "an", "brings", "them", "under", "JDO", "control", "." ]
9a544372f67ce965f662cdc71609dd03683c8f04
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/jdori/org/apache/ojb/jdori/sql/OjbExtent.java#L120-L147
train
kuali/ojb-1.0.4
src/java/org/apache/ojb/otm/copy/ReflectiveObjectCopyStrategy.java
ReflectiveObjectCopyStrategy.copy
public final Object copy(final Object toCopy, PersistenceBroker broker) { return clone(toCopy, IdentityMapFactory.getIdentityMap(), new HashMap()); }
java
public final Object copy(final Object toCopy, PersistenceBroker broker) { return clone(toCopy, IdentityMapFactory.getIdentityMap(), new HashMap()); }
[ "public", "final", "Object", "copy", "(", "final", "Object", "toCopy", ",", "PersistenceBroker", "broker", ")", "{", "return", "clone", "(", "toCopy", ",", "IdentityMapFactory", ".", "getIdentityMap", "(", ")", ",", "new", "HashMap", "(", ")", ")", ";", "}" ]
makes a deep clone of the object, using reflection. @param toCopy the object you want to copy @return
[ "makes", "a", "deep", "clone", "of", "the", "object", "using", "reflection", "." ]
9a544372f67ce965f662cdc71609dd03683c8f04
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/otm/copy/ReflectiveObjectCopyStrategy.java#L61-L64
train
kuali/ojb-1.0.4
src/java/org/apache/ojb/otm/copy/ReflectiveObjectCopyStrategy.java
ReflectiveObjectCopyStrategy.setFields
private static void setFields(final Object from, final Object to, final Field[] fields, final boolean accessible, final Map objMap, final Map metadataMap) { for (int f = 0, fieldsLength = fields.length; f < fieldsLength; ++f) { final Field field = fields[f]; final int modifiers = field.getModifiers(); if ((Modifier.STATIC & modifiers) != 0) continue; if ((Modifier.FINAL & modifiers) != 0) throw new ObjectCopyException("cannot set final field [" + field.getName() + "] of class [" + from.getClass().getName() + "]"); if (!accessible && ((Modifier.PUBLIC & modifiers) == 0)) { try { field.setAccessible(true); } catch (SecurityException e) { throw new ObjectCopyException("cannot access field [" + field.getName() + "] of class [" + from.getClass().getName() + "]: " + e.toString(), e); } } try { cloneAndSetFieldValue(field, from, to, objMap, metadataMap); } catch (Exception e) { throw new ObjectCopyException("cannot set field [" + field.getName() + "] of class [" + from.getClass().getName() + "]: " + e.toString(), e); } } }
java
private static void setFields(final Object from, final Object to, final Field[] fields, final boolean accessible, final Map objMap, final Map metadataMap) { for (int f = 0, fieldsLength = fields.length; f < fieldsLength; ++f) { final Field field = fields[f]; final int modifiers = field.getModifiers(); if ((Modifier.STATIC & modifiers) != 0) continue; if ((Modifier.FINAL & modifiers) != 0) throw new ObjectCopyException("cannot set final field [" + field.getName() + "] of class [" + from.getClass().getName() + "]"); if (!accessible && ((Modifier.PUBLIC & modifiers) == 0)) { try { field.setAccessible(true); } catch (SecurityException e) { throw new ObjectCopyException("cannot access field [" + field.getName() + "] of class [" + from.getClass().getName() + "]: " + e.toString(), e); } } try { cloneAndSetFieldValue(field, from, to, objMap, metadataMap); } catch (Exception e) { throw new ObjectCopyException("cannot set field [" + field.getName() + "] of class [" + from.getClass().getName() + "]: " + e.toString(), e); } } }
[ "private", "static", "void", "setFields", "(", "final", "Object", "from", ",", "final", "Object", "to", ",", "final", "Field", "[", "]", "fields", ",", "final", "boolean", "accessible", ",", "final", "Map", "objMap", ",", "final", "Map", "metadataMap", ")", "{", "for", "(", "int", "f", "=", "0", ",", "fieldsLength", "=", "fields", ".", "length", ";", "f", "<", "fieldsLength", ";", "++", "f", ")", "{", "final", "Field", "field", "=", "fields", "[", "f", "]", ";", "final", "int", "modifiers", "=", "field", ".", "getModifiers", "(", ")", ";", "if", "(", "(", "Modifier", ".", "STATIC", "&", "modifiers", ")", "!=", "0", ")", "continue", ";", "if", "(", "(", "Modifier", ".", "FINAL", "&", "modifiers", ")", "!=", "0", ")", "throw", "new", "ObjectCopyException", "(", "\"cannot set final field [\"", "+", "field", ".", "getName", "(", ")", "+", "\"] of class [\"", "+", "from", ".", "getClass", "(", ")", ".", "getName", "(", ")", "+", "\"]\"", ")", ";", "if", "(", "!", "accessible", "&&", "(", "(", "Modifier", ".", "PUBLIC", "&", "modifiers", ")", "==", "0", ")", ")", "{", "try", "{", "field", ".", "setAccessible", "(", "true", ")", ";", "}", "catch", "(", "SecurityException", "e", ")", "{", "throw", "new", "ObjectCopyException", "(", "\"cannot access field [\"", "+", "field", ".", "getName", "(", ")", "+", "\"] of class [\"", "+", "from", ".", "getClass", "(", ")", ".", "getName", "(", ")", "+", "\"]: \"", "+", "e", ".", "toString", "(", ")", ",", "e", ")", ";", "}", "}", "try", "{", "cloneAndSetFieldValue", "(", "field", ",", "from", ",", "to", ",", "objMap", ",", "metadataMap", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "ObjectCopyException", "(", "\"cannot set field [\"", "+", "field", ".", "getName", "(", ")", "+", "\"] of class [\"", "+", "from", ".", "getClass", "(", ")", ".", "getName", "(", ")", "+", "\"]: \"", "+", "e", ".", "toString", "(", ")", ",", "e", ")", ";", "}", "}", "}" ]
copy all fields from the "from" object to the "to" object. @param from source object @param to from's clone @param fields fields to be populated @param accessible 'true' if all 'fields' have been made accessible during traversal
[ "copy", "all", "fields", "from", "the", "from", "object", "to", "the", "to", "object", "." ]
9a544372f67ce965f662cdc71609dd03683c8f04
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/otm/copy/ReflectiveObjectCopyStrategy.java#L239-L270
train
kuali/ojb-1.0.4
src/tools/org/apache/ojb/tools/mapping/reversedb2/dnd2/DragHelper.java
DragHelper.registerComponent
public void registerComponent(java.awt.Component c) { unregisterComponent(c); if (recognizerAbstractClass == null) { hmDragGestureRecognizers.put(c, dragSource.createDefaultDragGestureRecognizer(c, dragWorker.getAcceptableActions(c), dgListener) ); } else { hmDragGestureRecognizers.put(c, dragSource.createDragGestureRecognizer (recognizerAbstractClass, c, dragWorker.getAcceptableActions(c), dgListener) ); } }
java
public void registerComponent(java.awt.Component c) { unregisterComponent(c); if (recognizerAbstractClass == null) { hmDragGestureRecognizers.put(c, dragSource.createDefaultDragGestureRecognizer(c, dragWorker.getAcceptableActions(c), dgListener) ); } else { hmDragGestureRecognizers.put(c, dragSource.createDragGestureRecognizer (recognizerAbstractClass, c, dragWorker.getAcceptableActions(c), dgListener) ); } }
[ "public", "void", "registerComponent", "(", "java", ".", "awt", ".", "Component", "c", ")", "{", "unregisterComponent", "(", "c", ")", ";", "if", "(", "recognizerAbstractClass", "==", "null", ")", "{", "hmDragGestureRecognizers", ".", "put", "(", "c", ",", "dragSource", ".", "createDefaultDragGestureRecognizer", "(", "c", ",", "dragWorker", ".", "getAcceptableActions", "(", "c", ")", ",", "dgListener", ")", ")", ";", "}", "else", "{", "hmDragGestureRecognizers", ".", "put", "(", "c", ",", "dragSource", ".", "createDragGestureRecognizer", "(", "recognizerAbstractClass", ",", "c", ",", "dragWorker", ".", "getAcceptableActions", "(", "c", ")", ",", "dgListener", ")", ")", ";", "}", "}" ]
add a Component to this Worker. After the call dragging is enabled for this Component. @param c the Component to register
[ "add", "a", "Component", "to", "this", "Worker", ".", "After", "the", "call", "dragging", "is", "enabled", "for", "this", "Component", "." ]
9a544372f67ce965f662cdc71609dd03683c8f04
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/tools/org/apache/ojb/tools/mapping/reversedb2/dnd2/DragHelper.java#L108-L125
train
kuali/ojb-1.0.4
src/tools/org/apache/ojb/tools/mapping/reversedb2/dnd2/DragHelper.java
DragHelper.unregisterComponent
public void unregisterComponent(java.awt.Component c) { java.awt.dnd.DragGestureRecognizer recognizer = (java.awt.dnd.DragGestureRecognizer)this.hmDragGestureRecognizers.remove(c); if (recognizer != null) recognizer.setComponent(null); }
java
public void unregisterComponent(java.awt.Component c) { java.awt.dnd.DragGestureRecognizer recognizer = (java.awt.dnd.DragGestureRecognizer)this.hmDragGestureRecognizers.remove(c); if (recognizer != null) recognizer.setComponent(null); }
[ "public", "void", "unregisterComponent", "(", "java", ".", "awt", ".", "Component", "c", ")", "{", "java", ".", "awt", ".", "dnd", ".", "DragGestureRecognizer", "recognizer", "=", "(", "java", ".", "awt", ".", "dnd", ".", "DragGestureRecognizer", ")", "this", ".", "hmDragGestureRecognizers", ".", "remove", "(", "c", ")", ";", "if", "(", "recognizer", "!=", "null", ")", "recognizer", ".", "setComponent", "(", "null", ")", ";", "}" ]
remove drag support from the given Component. @param c the Component to remove
[ "remove", "drag", "support", "from", "the", "given", "Component", "." ]
9a544372f67ce965f662cdc71609dd03683c8f04
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/tools/org/apache/ojb/tools/mapping/reversedb2/dnd2/DragHelper.java#L130-L136
train
kuali/ojb-1.0.4
src/java/org/apache/ojb/broker/util/interceptor/Interceptor.java
Interceptor.doInvoke
protected Object doInvoke(Object proxy, Method methodToBeInvoked, Object[] args) throws Throwable { Method m = getRealSubject().getClass().getMethod( methodToBeInvoked.getName(), methodToBeInvoked.getParameterTypes()); return m.invoke(getRealSubject(), args); }
java
protected Object doInvoke(Object proxy, Method methodToBeInvoked, Object[] args) throws Throwable { Method m = getRealSubject().getClass().getMethod( methodToBeInvoked.getName(), methodToBeInvoked.getParameterTypes()); return m.invoke(getRealSubject(), args); }
[ "protected", "Object", "doInvoke", "(", "Object", "proxy", ",", "Method", "methodToBeInvoked", ",", "Object", "[", "]", "args", ")", "throws", "Throwable", "{", "Method", "m", "=", "getRealSubject", "(", ")", ".", "getClass", "(", ")", ".", "getMethod", "(", "methodToBeInvoked", ".", "getName", "(", ")", ",", "methodToBeInvoked", ".", "getParameterTypes", "(", ")", ")", ";", "return", "m", ".", "invoke", "(", "getRealSubject", "(", ")", ",", "args", ")", ";", "}" ]
this method will be invoked after methodToBeInvoked is invoked
[ "this", "method", "will", "be", "invoked", "after", "methodToBeInvoked", "is", "invoked" ]
9a544372f67ce965f662cdc71609dd03683c8f04
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/util/interceptor/Interceptor.java#L62-L70
train
kuali/ojb-1.0.4
src/java/org/apache/ojb/broker/accesslayer/ChainingIterator.java
ChainingIterator.addIterator
public void addIterator(OJBIterator iterator) { /** * only add iterators that are not null and non-empty. */ if (iterator != null) { if (iterator.hasNext()) { setNextIterator(); m_rsIterators.add(iterator); } } }
java
public void addIterator(OJBIterator iterator) { /** * only add iterators that are not null and non-empty. */ if (iterator != null) { if (iterator.hasNext()) { setNextIterator(); m_rsIterators.add(iterator); } } }
[ "public", "void", "addIterator", "(", "OJBIterator", "iterator", ")", "{", "/**\r\n * only add iterators that are not null and non-empty.\r\n */", "if", "(", "iterator", "!=", "null", ")", "{", "if", "(", "iterator", ".", "hasNext", "(", ")", ")", "{", "setNextIterator", "(", ")", ";", "m_rsIterators", ".", "add", "(", "iterator", ")", ";", "}", "}", "}" ]
use this method to construct the ChainingIterator iterator by iterator.
[ "use", "this", "method", "to", "construct", "the", "ChainingIterator", "iterator", "by", "iterator", "." ]
9a544372f67ce965f662cdc71609dd03683c8f04
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/accesslayer/ChainingIterator.java#L90-L103
train
kuali/ojb-1.0.4
src/java/org/apache/ojb/broker/accesslayer/ChainingIterator.java
ChainingIterator.absolute
public boolean absolute(int row) throws PersistenceBrokerException { // 1. handle the special cases first. if (row == 0) { return true; } if (row == 1) { m_activeIteratorIndex = 0; m_activeIterator = (OJBIterator) m_rsIterators.get(m_activeIteratorIndex); m_activeIterator.absolute(1); return true; } if (row == -1) { m_activeIteratorIndex = m_rsIterators.size(); m_activeIterator = (OJBIterator) m_rsIterators.get(m_activeIteratorIndex); m_activeIterator.absolute(-1); return true; } // now do the real work. boolean movedToAbsolute = false; boolean retval = false; setNextIterator(); // row is positive, so index from beginning. if (row > 0) { int sizeCount = 0; Iterator it = m_rsIterators.iterator(); OJBIterator temp = null; while (it.hasNext() && !movedToAbsolute) { temp = (OJBIterator) it.next(); if (temp.size() < row) { sizeCount += temp.size(); } else { // move to the offset - sizecount m_currentCursorPosition = row - sizeCount; retval = temp.absolute(m_currentCursorPosition); movedToAbsolute = true; } } } // row is negative, so index from end else if (row < 0) { int sizeCount = 0; OJBIterator temp = null; for (int i = m_rsIterators.size(); ((i >= 0) && !movedToAbsolute); i--) { temp = (OJBIterator) m_rsIterators.get(i); if (temp.size() < row) { sizeCount += temp.size(); } else { // move to the offset - sizecount m_currentCursorPosition = row + sizeCount; retval = temp.absolute(m_currentCursorPosition); movedToAbsolute = true; } } } return retval; }
java
public boolean absolute(int row) throws PersistenceBrokerException { // 1. handle the special cases first. if (row == 0) { return true; } if (row == 1) { m_activeIteratorIndex = 0; m_activeIterator = (OJBIterator) m_rsIterators.get(m_activeIteratorIndex); m_activeIterator.absolute(1); return true; } if (row == -1) { m_activeIteratorIndex = m_rsIterators.size(); m_activeIterator = (OJBIterator) m_rsIterators.get(m_activeIteratorIndex); m_activeIterator.absolute(-1); return true; } // now do the real work. boolean movedToAbsolute = false; boolean retval = false; setNextIterator(); // row is positive, so index from beginning. if (row > 0) { int sizeCount = 0; Iterator it = m_rsIterators.iterator(); OJBIterator temp = null; while (it.hasNext() && !movedToAbsolute) { temp = (OJBIterator) it.next(); if (temp.size() < row) { sizeCount += temp.size(); } else { // move to the offset - sizecount m_currentCursorPosition = row - sizeCount; retval = temp.absolute(m_currentCursorPosition); movedToAbsolute = true; } } } // row is negative, so index from end else if (row < 0) { int sizeCount = 0; OJBIterator temp = null; for (int i = m_rsIterators.size(); ((i >= 0) && !movedToAbsolute); i--) { temp = (OJBIterator) m_rsIterators.get(i); if (temp.size() < row) { sizeCount += temp.size(); } else { // move to the offset - sizecount m_currentCursorPosition = row + sizeCount; retval = temp.absolute(m_currentCursorPosition); movedToAbsolute = true; } } } return retval; }
[ "public", "boolean", "absolute", "(", "int", "row", ")", "throws", "PersistenceBrokerException", "{", "// 1. handle the special cases first.\r", "if", "(", "row", "==", "0", ")", "{", "return", "true", ";", "}", "if", "(", "row", "==", "1", ")", "{", "m_activeIteratorIndex", "=", "0", ";", "m_activeIterator", "=", "(", "OJBIterator", ")", "m_rsIterators", ".", "get", "(", "m_activeIteratorIndex", ")", ";", "m_activeIterator", ".", "absolute", "(", "1", ")", ";", "return", "true", ";", "}", "if", "(", "row", "==", "-", "1", ")", "{", "m_activeIteratorIndex", "=", "m_rsIterators", ".", "size", "(", ")", ";", "m_activeIterator", "=", "(", "OJBIterator", ")", "m_rsIterators", ".", "get", "(", "m_activeIteratorIndex", ")", ";", "m_activeIterator", ".", "absolute", "(", "-", "1", ")", ";", "return", "true", ";", "}", "// now do the real work.\r", "boolean", "movedToAbsolute", "=", "false", ";", "boolean", "retval", "=", "false", ";", "setNextIterator", "(", ")", ";", "// row is positive, so index from beginning.\r", "if", "(", "row", ">", "0", ")", "{", "int", "sizeCount", "=", "0", ";", "Iterator", "it", "=", "m_rsIterators", ".", "iterator", "(", ")", ";", "OJBIterator", "temp", "=", "null", ";", "while", "(", "it", ".", "hasNext", "(", ")", "&&", "!", "movedToAbsolute", ")", "{", "temp", "=", "(", "OJBIterator", ")", "it", ".", "next", "(", ")", ";", "if", "(", "temp", ".", "size", "(", ")", "<", "row", ")", "{", "sizeCount", "+=", "temp", ".", "size", "(", ")", ";", "}", "else", "{", "// move to the offset - sizecount\r", "m_currentCursorPosition", "=", "row", "-", "sizeCount", ";", "retval", "=", "temp", ".", "absolute", "(", "m_currentCursorPosition", ")", ";", "movedToAbsolute", "=", "true", ";", "}", "}", "}", "// row is negative, so index from end\r", "else", "if", "(", "row", "<", "0", ")", "{", "int", "sizeCount", "=", "0", ";", "OJBIterator", "temp", "=", "null", ";", "for", "(", "int", "i", "=", "m_rsIterators", ".", "size", "(", ")", ";", "(", "(", "i", ">=", "0", ")", "&&", "!", "movedToAbsolute", ")", ";", "i", "--", ")", "{", "temp", "=", "(", "OJBIterator", ")", "m_rsIterators", ".", "get", "(", "i", ")", ";", "if", "(", "temp", ".", "size", "(", ")", "<", "row", ")", "{", "sizeCount", "+=", "temp", ".", "size", "(", ")", ";", "}", "else", "{", "// move to the offset - sizecount\r", "m_currentCursorPosition", "=", "row", "+", "sizeCount", ";", "retval", "=", "temp", ".", "absolute", "(", "m_currentCursorPosition", ")", ";", "movedToAbsolute", "=", "true", ";", "}", "}", "}", "return", "retval", ";", "}" ]
the absolute and relative calls are the trickiest parts. We have to move across cursor boundaries potentially. a + row value indexes from beginning of resultset a - row value indexes from the end of th resulset. Calling absolute(1) is the same as calling first(). Calling absolute(-1) is the same as calling last().
[ "the", "absolute", "and", "relative", "calls", "are", "the", "trickiest", "parts", ".", "We", "have", "to", "move", "across", "cursor", "boundaries", "potentially", "." ]
9a544372f67ce965f662cdc71609dd03683c8f04
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/accesslayer/ChainingIterator.java#L144-L219
train
kuali/ojb-1.0.4
src/java/org/apache/ojb/broker/accesslayer/ChainingIterator.java
ChainingIterator.releaseDbResources
public void releaseDbResources() { Iterator it = m_rsIterators.iterator(); while (it.hasNext()) { ((OJBIterator) it.next()).releaseDbResources(); } }
java
public void releaseDbResources() { Iterator it = m_rsIterators.iterator(); while (it.hasNext()) { ((OJBIterator) it.next()).releaseDbResources(); } }
[ "public", "void", "releaseDbResources", "(", ")", "{", "Iterator", "it", "=", "m_rsIterators", ".", "iterator", "(", ")", ";", "while", "(", "it", ".", "hasNext", "(", ")", ")", "{", "(", "(", "OJBIterator", ")", "it", ".", "next", "(", ")", ")", ".", "releaseDbResources", "(", ")", ";", "}", "}" ]
delegate to each contained OJBIterator and release its resources.
[ "delegate", "to", "each", "contained", "OJBIterator", "and", "release", "its", "resources", "." ]
9a544372f67ce965f662cdc71609dd03683c8f04
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/accesslayer/ChainingIterator.java#L288-L295
train
kuali/ojb-1.0.4
src/java/org/apache/ojb/broker/accesslayer/ChainingIterator.java
ChainingIterator.setNextIterator
private boolean setNextIterator() { boolean retval = false; // first, check if the activeIterator is null, and set it. if (m_activeIterator == null) { if (m_rsIterators.size() > 0) { m_activeIteratorIndex = 0; m_currentCursorPosition = 0; m_activeIterator = (OJBIterator) m_rsIterators.get(m_activeIteratorIndex); } } else if (!m_activeIterator.hasNext()) { if (m_rsIterators.size() > (m_activeIteratorIndex + 1)) { // we still have iterators in the collection, move to the // next one, increment the counter, and set the active // iterator. m_activeIteratorIndex++; m_currentCursorPosition = 0; m_activeIterator = (OJBIterator) m_rsIterators.get(m_activeIteratorIndex); retval = true; } } return retval; }
java
private boolean setNextIterator() { boolean retval = false; // first, check if the activeIterator is null, and set it. if (m_activeIterator == null) { if (m_rsIterators.size() > 0) { m_activeIteratorIndex = 0; m_currentCursorPosition = 0; m_activeIterator = (OJBIterator) m_rsIterators.get(m_activeIteratorIndex); } } else if (!m_activeIterator.hasNext()) { if (m_rsIterators.size() > (m_activeIteratorIndex + 1)) { // we still have iterators in the collection, move to the // next one, increment the counter, and set the active // iterator. m_activeIteratorIndex++; m_currentCursorPosition = 0; m_activeIterator = (OJBIterator) m_rsIterators.get(m_activeIteratorIndex); retval = true; } } return retval; }
[ "private", "boolean", "setNextIterator", "(", ")", "{", "boolean", "retval", "=", "false", ";", "// first, check if the activeIterator is null, and set it.\r", "if", "(", "m_activeIterator", "==", "null", ")", "{", "if", "(", "m_rsIterators", ".", "size", "(", ")", ">", "0", ")", "{", "m_activeIteratorIndex", "=", "0", ";", "m_currentCursorPosition", "=", "0", ";", "m_activeIterator", "=", "(", "OJBIterator", ")", "m_rsIterators", ".", "get", "(", "m_activeIteratorIndex", ")", ";", "}", "}", "else", "if", "(", "!", "m_activeIterator", ".", "hasNext", "(", ")", ")", "{", "if", "(", "m_rsIterators", ".", "size", "(", ")", ">", "(", "m_activeIteratorIndex", "+", "1", ")", ")", "{", "// we still have iterators in the collection, move to the\r", "// next one, increment the counter, and set the active\r", "// iterator.\r", "m_activeIteratorIndex", "++", ";", "m_currentCursorPosition", "=", "0", ";", "m_activeIterator", "=", "(", "OJBIterator", ")", "m_rsIterators", ".", "get", "(", "m_activeIteratorIndex", ")", ";", "retval", "=", "true", ";", "}", "}", "return", "retval", ";", "}" ]
Convenience routine to move to the next iterator if needed. @return true if the iterator is changed, false if no changes.
[ "Convenience", "routine", "to", "move", "to", "the", "next", "iterator", "if", "needed", "." ]
9a544372f67ce965f662cdc71609dd03683c8f04
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/accesslayer/ChainingIterator.java#L338-L366
train
kuali/ojb-1.0.4
src/java/org/apache/ojb/broker/accesslayer/ChainingIterator.java
ChainingIterator.containsIteratorForTable
public boolean containsIteratorForTable(String aTable) { boolean result = false; if (m_rsIterators != null) { for (int i = 0; i < m_rsIterators.size(); i++) { OJBIterator it = (OJBIterator) m_rsIterators.get(i); if (it instanceof RsIterator) { if (((RsIterator) it).getClassDescriptor().getFullTableName().equals(aTable)) { result = true; break; } } else if (it instanceof ChainingIterator) { result = ((ChainingIterator) it).containsIteratorForTable(aTable); } } } return result; }
java
public boolean containsIteratorForTable(String aTable) { boolean result = false; if (m_rsIterators != null) { for (int i = 0; i < m_rsIterators.size(); i++) { OJBIterator it = (OJBIterator) m_rsIterators.get(i); if (it instanceof RsIterator) { if (((RsIterator) it).getClassDescriptor().getFullTableName().equals(aTable)) { result = true; break; } } else if (it instanceof ChainingIterator) { result = ((ChainingIterator) it).containsIteratorForTable(aTable); } } } return result; }
[ "public", "boolean", "containsIteratorForTable", "(", "String", "aTable", ")", "{", "boolean", "result", "=", "false", ";", "if", "(", "m_rsIterators", "!=", "null", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "m_rsIterators", ".", "size", "(", ")", ";", "i", "++", ")", "{", "OJBIterator", "it", "=", "(", "OJBIterator", ")", "m_rsIterators", ".", "get", "(", "i", ")", ";", "if", "(", "it", "instanceof", "RsIterator", ")", "{", "if", "(", "(", "(", "RsIterator", ")", "it", ")", ".", "getClassDescriptor", "(", ")", ".", "getFullTableName", "(", ")", ".", "equals", "(", "aTable", ")", ")", "{", "result", "=", "true", ";", "break", ";", "}", "}", "else", "if", "(", "it", "instanceof", "ChainingIterator", ")", "{", "result", "=", "(", "(", "ChainingIterator", ")", "it", ")", ".", "containsIteratorForTable", "(", "aTable", ")", ";", "}", "}", "}", "return", "result", ";", "}" ]
Answer true if an Iterator for a Table is already available @param aTable @return
[ "Answer", "true", "if", "an", "Iterator", "for", "a", "Table", "is", "already", "available" ]
9a544372f67ce965f662cdc71609dd03683c8f04
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/accesslayer/ChainingIterator.java#L373-L398
train
kuali/ojb-1.0.4
src/java/org/apache/ojb/broker/query/QueryByIdentity.java
QueryByIdentity.getSearchClass
public Class getSearchClass() { Object obj = getExampleObject(); if (obj instanceof Identity) { return ((Identity) obj).getObjectsTopLevelClass(); } else { return obj.getClass(); } }
java
public Class getSearchClass() { Object obj = getExampleObject(); if (obj instanceof Identity) { return ((Identity) obj).getObjectsTopLevelClass(); } else { return obj.getClass(); } }
[ "public", "Class", "getSearchClass", "(", ")", "{", "Object", "obj", "=", "getExampleObject", "(", ")", ";", "if", "(", "obj", "instanceof", "Identity", ")", "{", "return", "(", "(", "Identity", ")", "obj", ")", ".", "getObjectsTopLevelClass", "(", ")", ";", "}", "else", "{", "return", "obj", ".", "getClass", "(", ")", ";", "}", "}" ]
Answer the search class. This is the class of the example object or the class represented by Identity. @return Class
[ "Answer", "the", "search", "class", ".", "This", "is", "the", "class", "of", "the", "example", "object", "or", "the", "class", "represented", "by", "Identity", "." ]
9a544372f67ce965f662cdc71609dd03683c8f04
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/query/QueryByIdentity.java#L87-L99
train
geomajas/geomajas-project-server
impl/src/main/java/org/geomajas/internal/service/ConfigurationServiceImpl.java
ConfigurationServiceImpl.getBeanOrNull
private <T> T getBeanOrNull(String name, Class<T> requiredType) { if (name == null || !applicationContext.containsBean(name)) { return null; } else { try { return applicationContext.getBean(name, requiredType); } catch (BeansException be) { log.error("Error during getBeanOrNull, not rethrown, " + be.getMessage(), be); return null; } } }
java
private <T> T getBeanOrNull(String name, Class<T> requiredType) { if (name == null || !applicationContext.containsBean(name)) { return null; } else { try { return applicationContext.getBean(name, requiredType); } catch (BeansException be) { log.error("Error during getBeanOrNull, not rethrown, " + be.getMessage(), be); return null; } } }
[ "private", "<", "T", ">", "T", "getBeanOrNull", "(", "String", "name", ",", "Class", "<", "T", ">", "requiredType", ")", "{", "if", "(", "name", "==", "null", "||", "!", "applicationContext", ".", "containsBean", "(", "name", ")", ")", "{", "return", "null", ";", "}", "else", "{", "try", "{", "return", "applicationContext", ".", "getBean", "(", "name", ",", "requiredType", ")", ";", "}", "catch", "(", "BeansException", "be", ")", "{", "log", ".", "error", "(", "\"Error during getBeanOrNull, not rethrown, \"", "+", "be", ".", "getMessage", "(", ")", ",", "be", ")", ";", "return", "null", ";", "}", "}", "}" ]
Get a bean from the application context. Returns null if the bean does not exist. @param name name of bean @param requiredType type of bean @return the bean or null
[ "Get", "a", "bean", "from", "the", "application", "context", ".", "Returns", "null", "if", "the", "bean", "does", "not", "exist", "." ]
904b7d7deed1350d28955589098dd1e0a786d76e
https://github.com/geomajas/geomajas-project-server/blob/904b7d7deed1350d28955589098dd1e0a786d76e/impl/src/main/java/org/geomajas/internal/service/ConfigurationServiceImpl.java#L105-L116
train
geomajas/geomajas-project-server
plugin/cache/cache/src/main/java/org/geomajas/plugin/caching/service/CachingSupportServiceSecurityContextAdderImpl.java
CachingSupportServiceSecurityContextAdderImpl.restoreSecurityContext
public void restoreSecurityContext(CacheContext context) { SavedAuthorization cached = context.get(CacheContext.SECURITY_CONTEXT_KEY, SavedAuthorization.class); if (cached != null) { log.debug("Restoring security context {}", cached); securityManager.restoreSecurityContext(cached); } else { securityManager.clearSecurityContext(); } }
java
public void restoreSecurityContext(CacheContext context) { SavedAuthorization cached = context.get(CacheContext.SECURITY_CONTEXT_KEY, SavedAuthorization.class); if (cached != null) { log.debug("Restoring security context {}", cached); securityManager.restoreSecurityContext(cached); } else { securityManager.clearSecurityContext(); } }
[ "public", "void", "restoreSecurityContext", "(", "CacheContext", "context", ")", "{", "SavedAuthorization", "cached", "=", "context", ".", "get", "(", "CacheContext", ".", "SECURITY_CONTEXT_KEY", ",", "SavedAuthorization", ".", "class", ")", ";", "if", "(", "cached", "!=", "null", ")", "{", "log", ".", "debug", "(", "\"Restoring security context {}\"", ",", "cached", ")", ";", "securityManager", ".", "restoreSecurityContext", "(", "cached", ")", ";", "}", "else", "{", "securityManager", ".", "clearSecurityContext", "(", ")", ";", "}", "}" ]
Puts the cached security context in the thread local. @param context the cache context
[ "Puts", "the", "cached", "security", "context", "in", "the", "thread", "local", "." ]
904b7d7deed1350d28955589098dd1e0a786d76e
https://github.com/geomajas/geomajas-project-server/blob/904b7d7deed1350d28955589098dd1e0a786d76e/plugin/cache/cache/src/main/java/org/geomajas/plugin/caching/service/CachingSupportServiceSecurityContextAdderImpl.java#L42-L50
train
foundation-runtime/logging
logging-log4j/src/main/java/com/cisco/oss/foundation/logging/appender/LogFileList.java
LogFileList.sortFileList
private void sortFileList() { if (this.size() > 1) { Collections.sort(this.fileList, new Comparator() { public final int compare(final Object o1, final Object o2) { final File f1 = (File) o1; final File f2 = (File) o2; final Object[] f1TimeAndCount = backupSuffixHelper .backupTimeAndCount(f1.getName(), baseFile); final Object[] f2TimeAndCount = backupSuffixHelper .backupTimeAndCount(f2.getName(), baseFile); final long f1TimeSuffix = ((Long) f1TimeAndCount[0]).longValue(); final long f2TimeSuffix = ((Long) f2TimeAndCount[0]).longValue(); if ((0L == f1TimeSuffix) && (0L == f2TimeSuffix)) { final long f1Time = f1.lastModified(); final long f2Time = f2.lastModified(); if (f1Time < f2Time) { return -1; } if (f1Time > f2Time) { return 1; } return 0; } if (f1TimeSuffix < f2TimeSuffix) { return -1; } if (f1TimeSuffix > f2TimeSuffix) { return 1; } final int f1Count = ((Integer) f1TimeAndCount[1]).intValue(); final int f2Count = ((Integer) f2TimeAndCount[1]).intValue(); if (f1Count < f2Count) { return -1; } if (f1Count > f2Count) { return 1; } if (f1Count == f2Count) { if (fileHelper.isCompressed(f1)) { return -1; } if (fileHelper.isCompressed(f2)) { return 1; } } return 0; } }); } }
java
private void sortFileList() { if (this.size() > 1) { Collections.sort(this.fileList, new Comparator() { public final int compare(final Object o1, final Object o2) { final File f1 = (File) o1; final File f2 = (File) o2; final Object[] f1TimeAndCount = backupSuffixHelper .backupTimeAndCount(f1.getName(), baseFile); final Object[] f2TimeAndCount = backupSuffixHelper .backupTimeAndCount(f2.getName(), baseFile); final long f1TimeSuffix = ((Long) f1TimeAndCount[0]).longValue(); final long f2TimeSuffix = ((Long) f2TimeAndCount[0]).longValue(); if ((0L == f1TimeSuffix) && (0L == f2TimeSuffix)) { final long f1Time = f1.lastModified(); final long f2Time = f2.lastModified(); if (f1Time < f2Time) { return -1; } if (f1Time > f2Time) { return 1; } return 0; } if (f1TimeSuffix < f2TimeSuffix) { return -1; } if (f1TimeSuffix > f2TimeSuffix) { return 1; } final int f1Count = ((Integer) f1TimeAndCount[1]).intValue(); final int f2Count = ((Integer) f2TimeAndCount[1]).intValue(); if (f1Count < f2Count) { return -1; } if (f1Count > f2Count) { return 1; } if (f1Count == f2Count) { if (fileHelper.isCompressed(f1)) { return -1; } if (fileHelper.isCompressed(f2)) { return 1; } } return 0; } }); } }
[ "private", "void", "sortFileList", "(", ")", "{", "if", "(", "this", ".", "size", "(", ")", ">", "1", ")", "{", "Collections", ".", "sort", "(", "this", ".", "fileList", ",", "new", "Comparator", "(", ")", "{", "public", "final", "int", "compare", "(", "final", "Object", "o1", ",", "final", "Object", "o2", ")", "{", "final", "File", "f1", "=", "(", "File", ")", "o1", ";", "final", "File", "f2", "=", "(", "File", ")", "o2", ";", "final", "Object", "[", "]", "f1TimeAndCount", "=", "backupSuffixHelper", ".", "backupTimeAndCount", "(", "f1", ".", "getName", "(", ")", ",", "baseFile", ")", ";", "final", "Object", "[", "]", "f2TimeAndCount", "=", "backupSuffixHelper", ".", "backupTimeAndCount", "(", "f2", ".", "getName", "(", ")", ",", "baseFile", ")", ";", "final", "long", "f1TimeSuffix", "=", "(", "(", "Long", ")", "f1TimeAndCount", "[", "0", "]", ")", ".", "longValue", "(", ")", ";", "final", "long", "f2TimeSuffix", "=", "(", "(", "Long", ")", "f2TimeAndCount", "[", "0", "]", ")", ".", "longValue", "(", ")", ";", "if", "(", "(", "0L", "==", "f1TimeSuffix", ")", "&&", "(", "0L", "==", "f2TimeSuffix", ")", ")", "{", "final", "long", "f1Time", "=", "f1", ".", "lastModified", "(", ")", ";", "final", "long", "f2Time", "=", "f2", ".", "lastModified", "(", ")", ";", "if", "(", "f1Time", "<", "f2Time", ")", "{", "return", "-", "1", ";", "}", "if", "(", "f1Time", ">", "f2Time", ")", "{", "return", "1", ";", "}", "return", "0", ";", "}", "if", "(", "f1TimeSuffix", "<", "f2TimeSuffix", ")", "{", "return", "-", "1", ";", "}", "if", "(", "f1TimeSuffix", ">", "f2TimeSuffix", ")", "{", "return", "1", ";", "}", "final", "int", "f1Count", "=", "(", "(", "Integer", ")", "f1TimeAndCount", "[", "1", "]", ")", ".", "intValue", "(", ")", ";", "final", "int", "f2Count", "=", "(", "(", "Integer", ")", "f2TimeAndCount", "[", "1", "]", ")", ".", "intValue", "(", ")", ";", "if", "(", "f1Count", "<", "f2Count", ")", "{", "return", "-", "1", ";", "}", "if", "(", "f1Count", ">", "f2Count", ")", "{", "return", "1", ";", "}", "if", "(", "f1Count", "==", "f2Count", ")", "{", "if", "(", "fileHelper", ".", "isCompressed", "(", "f1", ")", ")", "{", "return", "-", "1", ";", "}", "if", "(", "fileHelper", ".", "isCompressed", "(", "f2", ")", ")", "{", "return", "1", ";", "}", "}", "return", "0", ";", "}", "}", ")", ";", "}", "}" ]
Sort by time bucket, then backup count, and by compression state.
[ "Sort", "by", "time", "bucket", "then", "backup", "count", "and", "by", "compression", "state", "." ]
cd0a07b3c5b458ecf90ab92a1e0c72a067f5cbd6
https://github.com/foundation-runtime/logging/blob/cd0a07b3c5b458ecf90ab92a1e0c72a067f5cbd6/logging-log4j/src/main/java/com/cisco/oss/foundation/logging/appender/LogFileList.java#L125-L175
train
kuali/ojb-1.0.4
src/java/org/apache/ojb/broker/util/BrokerHelper.java
BrokerHelper.getRealClassDescriptor
private ClassDescriptor getRealClassDescriptor(ClassDescriptor aCld, Object anObj) { ClassDescriptor result; if(aCld.getClassOfObject() == ProxyHelper.getRealClass(anObj)) { result = aCld; } else { result = aCld.getRepository().getDescriptorFor(anObj.getClass()); } return result; }
java
private ClassDescriptor getRealClassDescriptor(ClassDescriptor aCld, Object anObj) { ClassDescriptor result; if(aCld.getClassOfObject() == ProxyHelper.getRealClass(anObj)) { result = aCld; } else { result = aCld.getRepository().getDescriptorFor(anObj.getClass()); } return result; }
[ "private", "ClassDescriptor", "getRealClassDescriptor", "(", "ClassDescriptor", "aCld", ",", "Object", "anObj", ")", "{", "ClassDescriptor", "result", ";", "if", "(", "aCld", ".", "getClassOfObject", "(", ")", "==", "ProxyHelper", ".", "getRealClass", "(", "anObj", ")", ")", "{", "result", "=", "aCld", ";", "}", "else", "{", "result", "=", "aCld", ".", "getRepository", "(", ")", ".", "getDescriptorFor", "(", "anObj", ".", "getClass", "(", ")", ")", ";", "}", "return", "result", ";", "}" ]
Answer the real ClassDescriptor for anObj ie. aCld may be an Interface of anObj, so the cld for anObj is returned
[ "Answer", "the", "real", "ClassDescriptor", "for", "anObj", "ie", ".", "aCld", "may", "be", "an", "Interface", "of", "anObj", "so", "the", "cld", "for", "anObj", "is", "returned" ]
9a544372f67ce965f662cdc71609dd03683c8f04
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/util/BrokerHelper.java#L141-L155
train
kuali/ojb-1.0.4
src/java/org/apache/ojb/broker/util/BrokerHelper.java
BrokerHelper.getKeyValues
public ValueContainer[] getKeyValues(ClassDescriptor cld, Object objectOrProxy, boolean convertToSql) throws PersistenceBrokerException { IndirectionHandler handler = ProxyHelper.getIndirectionHandler(objectOrProxy); if(handler != null) { return getKeyValues(cld, handler.getIdentity(), convertToSql); //BRJ: convert Identity } else { ClassDescriptor realCld = getRealClassDescriptor(cld, objectOrProxy); return getValuesForObject(realCld.getPkFields(), objectOrProxy, convertToSql); } }
java
public ValueContainer[] getKeyValues(ClassDescriptor cld, Object objectOrProxy, boolean convertToSql) throws PersistenceBrokerException { IndirectionHandler handler = ProxyHelper.getIndirectionHandler(objectOrProxy); if(handler != null) { return getKeyValues(cld, handler.getIdentity(), convertToSql); //BRJ: convert Identity } else { ClassDescriptor realCld = getRealClassDescriptor(cld, objectOrProxy); return getValuesForObject(realCld.getPkFields(), objectOrProxy, convertToSql); } }
[ "public", "ValueContainer", "[", "]", "getKeyValues", "(", "ClassDescriptor", "cld", ",", "Object", "objectOrProxy", ",", "boolean", "convertToSql", ")", "throws", "PersistenceBrokerException", "{", "IndirectionHandler", "handler", "=", "ProxyHelper", ".", "getIndirectionHandler", "(", "objectOrProxy", ")", ";", "if", "(", "handler", "!=", "null", ")", "{", "return", "getKeyValues", "(", "cld", ",", "handler", ".", "getIdentity", "(", ")", ",", "convertToSql", ")", ";", "//BRJ: convert Identity\r", "}", "else", "{", "ClassDescriptor", "realCld", "=", "getRealClassDescriptor", "(", "cld", ",", "objectOrProxy", ")", ";", "return", "getValuesForObject", "(", "realCld", ".", "getPkFields", "(", ")", ",", "objectOrProxy", ",", "convertToSql", ")", ";", "}", "}" ]
Returns an Array with an Objects PK VALUES if convertToSql is true, any associated java-to-sql conversions are applied. If the Object is a Proxy or a VirtualProxy NO conversion is necessary. @param objectOrProxy @param convertToSql @return Object[] @throws PersistenceBrokerException
[ "Returns", "an", "Array", "with", "an", "Objects", "PK", "VALUES", "if", "convertToSql", "is", "true", "any", "associated", "java", "-", "to", "-", "sql", "conversions", "are", "applied", ".", "If", "the", "Object", "is", "a", "Proxy", "or", "a", "VirtualProxy", "NO", "conversion", "is", "necessary", "." ]
9a544372f67ce965f662cdc71609dd03683c8f04
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/util/BrokerHelper.java#L167-L180
train
kuali/ojb-1.0.4
src/java/org/apache/ojb/broker/util/BrokerHelper.java
BrokerHelper.getKeyValues
public ValueContainer[] getKeyValues(ClassDescriptor cld, Identity oid) throws PersistenceBrokerException { return getKeyValues(cld, oid, true); }
java
public ValueContainer[] getKeyValues(ClassDescriptor cld, Identity oid) throws PersistenceBrokerException { return getKeyValues(cld, oid, true); }
[ "public", "ValueContainer", "[", "]", "getKeyValues", "(", "ClassDescriptor", "cld", ",", "Identity", "oid", ")", "throws", "PersistenceBrokerException", "{", "return", "getKeyValues", "(", "cld", ",", "oid", ",", "true", ")", ";", "}" ]
Return primary key values of given Identity object. @param cld @param oid @return Object[] @throws PersistenceBrokerException
[ "Return", "primary", "key", "values", "of", "given", "Identity", "object", "." ]
9a544372f67ce965f662cdc71609dd03683c8f04
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/util/BrokerHelper.java#L190-L193
train
kuali/ojb-1.0.4
src/java/org/apache/ojb/broker/util/BrokerHelper.java
BrokerHelper.getKeyValues
public ValueContainer[] getKeyValues(ClassDescriptor cld, Identity oid, boolean convertToSql) throws PersistenceBrokerException { FieldDescriptor[] pkFields = cld.getPkFields(); ValueContainer[] result = new ValueContainer[pkFields.length]; Object[] pkValues = oid.getPrimaryKeyValues(); try { for(int i = 0; i < result.length; i++) { FieldDescriptor fd = pkFields[i]; Object cv = pkValues[i]; if(convertToSql) { // BRJ : apply type and value mapping cv = fd.getFieldConversion().javaToSql(cv); } result[i] = new ValueContainer(cv, fd.getJdbcType()); } } catch(Exception e) { throw new PersistenceBrokerException("Can't generate primary key values for given Identity " + oid, e); } return result; }
java
public ValueContainer[] getKeyValues(ClassDescriptor cld, Identity oid, boolean convertToSql) throws PersistenceBrokerException { FieldDescriptor[] pkFields = cld.getPkFields(); ValueContainer[] result = new ValueContainer[pkFields.length]; Object[] pkValues = oid.getPrimaryKeyValues(); try { for(int i = 0; i < result.length; i++) { FieldDescriptor fd = pkFields[i]; Object cv = pkValues[i]; if(convertToSql) { // BRJ : apply type and value mapping cv = fd.getFieldConversion().javaToSql(cv); } result[i] = new ValueContainer(cv, fd.getJdbcType()); } } catch(Exception e) { throw new PersistenceBrokerException("Can't generate primary key values for given Identity " + oid, e); } return result; }
[ "public", "ValueContainer", "[", "]", "getKeyValues", "(", "ClassDescriptor", "cld", ",", "Identity", "oid", ",", "boolean", "convertToSql", ")", "throws", "PersistenceBrokerException", "{", "FieldDescriptor", "[", "]", "pkFields", "=", "cld", ".", "getPkFields", "(", ")", ";", "ValueContainer", "[", "]", "result", "=", "new", "ValueContainer", "[", "pkFields", ".", "length", "]", ";", "Object", "[", "]", "pkValues", "=", "oid", ".", "getPrimaryKeyValues", "(", ")", ";", "try", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "result", ".", "length", ";", "i", "++", ")", "{", "FieldDescriptor", "fd", "=", "pkFields", "[", "i", "]", ";", "Object", "cv", "=", "pkValues", "[", "i", "]", ";", "if", "(", "convertToSql", ")", "{", "// BRJ : apply type and value mapping\r", "cv", "=", "fd", ".", "getFieldConversion", "(", ")", ".", "javaToSql", "(", "cv", ")", ";", "}", "result", "[", "i", "]", "=", "new", "ValueContainer", "(", "cv", ",", "fd", ".", "getJdbcType", "(", ")", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "PersistenceBrokerException", "(", "\"Can't generate primary key values for given Identity \"", "+", "oid", ",", "e", ")", ";", "}", "return", "result", ";", "}" ]
Return key Values of an Identity @param cld @param oid @param convertToSql @return Object[] @throws PersistenceBrokerException
[ "Return", "key", "Values", "of", "an", "Identity" ]
9a544372f67ce965f662cdc71609dd03683c8f04
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/util/BrokerHelper.java#L203-L228
train
kuali/ojb-1.0.4
src/java/org/apache/ojb/broker/util/BrokerHelper.java
BrokerHelper.getKeyValues
public ValueContainer[] getKeyValues(ClassDescriptor cld, Object objectOrProxy) throws PersistenceBrokerException { return getKeyValues(cld, objectOrProxy, true); }
java
public ValueContainer[] getKeyValues(ClassDescriptor cld, Object objectOrProxy) throws PersistenceBrokerException { return getKeyValues(cld, objectOrProxy, true); }
[ "public", "ValueContainer", "[", "]", "getKeyValues", "(", "ClassDescriptor", "cld", ",", "Object", "objectOrProxy", ")", "throws", "PersistenceBrokerException", "{", "return", "getKeyValues", "(", "cld", ",", "objectOrProxy", ",", "true", ")", ";", "}" ]
returns an Array with an Objects PK VALUES, with any java-to-sql FieldConversion applied. If the Object is a Proxy or a VirtualProxy NO conversion is necessary. @param objectOrProxy @return Object[] @throws PersistenceBrokerException
[ "returns", "an", "Array", "with", "an", "Objects", "PK", "VALUES", "with", "any", "java", "-", "to", "-", "sql", "FieldConversion", "applied", ".", "If", "the", "Object", "is", "a", "Proxy", "or", "a", "VirtualProxy", "NO", "conversion", "is", "necessary", "." ]
9a544372f67ce965f662cdc71609dd03683c8f04
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/util/BrokerHelper.java#L239-L242
train
kuali/ojb-1.0.4
src/java/org/apache/ojb/broker/util/BrokerHelper.java
BrokerHelper.hasNullPKField
public boolean hasNullPKField(ClassDescriptor cld, Object obj) { FieldDescriptor[] fields = cld.getPkFields(); boolean hasNull = false; // an unmaterialized proxy object can never have nullified PK's IndirectionHandler handler = ProxyHelper.getIndirectionHandler(obj); if(handler == null || handler.alreadyMaterialized()) { if(handler != null) obj = handler.getRealSubject(); FieldDescriptor fld; for(int i = 0; i < fields.length; i++) { fld = fields[i]; hasNull = representsNull(fld, fld.getPersistentField().get(obj)); if(hasNull) break; } } return hasNull; }
java
public boolean hasNullPKField(ClassDescriptor cld, Object obj) { FieldDescriptor[] fields = cld.getPkFields(); boolean hasNull = false; // an unmaterialized proxy object can never have nullified PK's IndirectionHandler handler = ProxyHelper.getIndirectionHandler(obj); if(handler == null || handler.alreadyMaterialized()) { if(handler != null) obj = handler.getRealSubject(); FieldDescriptor fld; for(int i = 0; i < fields.length; i++) { fld = fields[i]; hasNull = representsNull(fld, fld.getPersistentField().get(obj)); if(hasNull) break; } } return hasNull; }
[ "public", "boolean", "hasNullPKField", "(", "ClassDescriptor", "cld", ",", "Object", "obj", ")", "{", "FieldDescriptor", "[", "]", "fields", "=", "cld", ".", "getPkFields", "(", ")", ";", "boolean", "hasNull", "=", "false", ";", "// an unmaterialized proxy object can never have nullified PK's\r", "IndirectionHandler", "handler", "=", "ProxyHelper", ".", "getIndirectionHandler", "(", "obj", ")", ";", "if", "(", "handler", "==", "null", "||", "handler", ".", "alreadyMaterialized", "(", ")", ")", "{", "if", "(", "handler", "!=", "null", ")", "obj", "=", "handler", ".", "getRealSubject", "(", ")", ";", "FieldDescriptor", "fld", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "fields", ".", "length", ";", "i", "++", ")", "{", "fld", "=", "fields", "[", "i", "]", ";", "hasNull", "=", "representsNull", "(", "fld", ",", "fld", ".", "getPersistentField", "(", ")", ".", "get", "(", "obj", ")", ")", ";", "if", "(", "hasNull", ")", "break", ";", "}", "}", "return", "hasNull", ";", "}" ]
Detect if the given object has a PK field represents a 'null' value.
[ "Detect", "if", "the", "given", "object", "has", "a", "PK", "field", "represents", "a", "null", "value", "." ]
9a544372f67ce965f662cdc71609dd03683c8f04
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/util/BrokerHelper.java#L286-L304
train
kuali/ojb-1.0.4
src/java/org/apache/ojb/broker/util/BrokerHelper.java
BrokerHelper.getValuesForObject
public ValueContainer[] getValuesForObject(FieldDescriptor[] fields, Object obj, boolean convertToSql, boolean assignAutoincrement) throws PersistenceBrokerException { ValueContainer[] result = new ValueContainer[fields.length]; for(int i = 0; i < fields.length; i++) { FieldDescriptor fd = fields[i]; Object cv = fd.getPersistentField().get(obj); /* handle autoincrement attributes if - is a autoincrement field - field represents a 'null' value, is nullified and generate a new value */ if(assignAutoincrement && fd.isAutoIncrement() && representsNull(fd, cv)) { /* setAutoIncrementValue returns a value that is properly typed for the java-world. This value needs to be converted to it's corresponding sql type so that the entire result array contains objects that are properly typed for sql. */ cv = setAutoIncrementValue(fd, obj); } if(convertToSql) { // apply type and value conversion cv = fd.getFieldConversion().javaToSql(cv); } // create ValueContainer result[i] = new ValueContainer(cv, fd.getJdbcType()); } return result; }
java
public ValueContainer[] getValuesForObject(FieldDescriptor[] fields, Object obj, boolean convertToSql, boolean assignAutoincrement) throws PersistenceBrokerException { ValueContainer[] result = new ValueContainer[fields.length]; for(int i = 0; i < fields.length; i++) { FieldDescriptor fd = fields[i]; Object cv = fd.getPersistentField().get(obj); /* handle autoincrement attributes if - is a autoincrement field - field represents a 'null' value, is nullified and generate a new value */ if(assignAutoincrement && fd.isAutoIncrement() && representsNull(fd, cv)) { /* setAutoIncrementValue returns a value that is properly typed for the java-world. This value needs to be converted to it's corresponding sql type so that the entire result array contains objects that are properly typed for sql. */ cv = setAutoIncrementValue(fd, obj); } if(convertToSql) { // apply type and value conversion cv = fd.getFieldConversion().javaToSql(cv); } // create ValueContainer result[i] = new ValueContainer(cv, fd.getJdbcType()); } return result; }
[ "public", "ValueContainer", "[", "]", "getValuesForObject", "(", "FieldDescriptor", "[", "]", "fields", ",", "Object", "obj", ",", "boolean", "convertToSql", ",", "boolean", "assignAutoincrement", ")", "throws", "PersistenceBrokerException", "{", "ValueContainer", "[", "]", "result", "=", "new", "ValueContainer", "[", "fields", ".", "length", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "fields", ".", "length", ";", "i", "++", ")", "{", "FieldDescriptor", "fd", "=", "fields", "[", "i", "]", ";", "Object", "cv", "=", "fd", ".", "getPersistentField", "(", ")", ".", "get", "(", "obj", ")", ";", "/*\r\n handle autoincrement attributes if\r\n - is a autoincrement field\r\n - field represents a 'null' value, is nullified\r\n and generate a new value\r\n */", "if", "(", "assignAutoincrement", "&&", "fd", ".", "isAutoIncrement", "(", ")", "&&", "representsNull", "(", "fd", ",", "cv", ")", ")", "{", "/*\r\n setAutoIncrementValue returns a value that is\r\n properly typed for the java-world. This value\r\n needs to be converted to it's corresponding\r\n sql type so that the entire result array contains\r\n objects that are properly typed for sql.\r\n */", "cv", "=", "setAutoIncrementValue", "(", "fd", ",", "obj", ")", ";", "}", "if", "(", "convertToSql", ")", "{", "// apply type and value conversion\r", "cv", "=", "fd", ".", "getFieldConversion", "(", ")", ".", "javaToSql", "(", "cv", ")", ";", "}", "// create ValueContainer\r", "result", "[", "i", "]", "=", "new", "ValueContainer", "(", "cv", ",", "fd", ".", "getJdbcType", "(", ")", ")", ";", "}", "return", "result", ";", "}" ]
Get the values of the fields for an obj Autoincrement values are automatically set. @param fields @param obj @throws PersistenceBrokerException
[ "Get", "the", "values", "of", "the", "fields", "for", "an", "obj", "Autoincrement", "values", "are", "automatically", "set", "." ]
9a544372f67ce965f662cdc71609dd03683c8f04
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/util/BrokerHelper.java#L349-L384
train
kuali/ojb-1.0.4
src/java/org/apache/ojb/broker/util/BrokerHelper.java
BrokerHelper.assertValidPkForDelete
public boolean assertValidPkForDelete(ClassDescriptor cld, Object obj) { if(!ProxyHelper.isProxy(obj)) { FieldDescriptor fieldDescriptors[] = cld.getPkFields(); int fieldDescriptorSize = fieldDescriptors.length; for(int i = 0; i < fieldDescriptorSize; i++) { FieldDescriptor fd = fieldDescriptors[i]; Object pkValue = fd.getPersistentField().get(obj); if (representsNull(fd, pkValue)) { return false; } } } return true; }
java
public boolean assertValidPkForDelete(ClassDescriptor cld, Object obj) { if(!ProxyHelper.isProxy(obj)) { FieldDescriptor fieldDescriptors[] = cld.getPkFields(); int fieldDescriptorSize = fieldDescriptors.length; for(int i = 0; i < fieldDescriptorSize; i++) { FieldDescriptor fd = fieldDescriptors[i]; Object pkValue = fd.getPersistentField().get(obj); if (representsNull(fd, pkValue)) { return false; } } } return true; }
[ "public", "boolean", "assertValidPkForDelete", "(", "ClassDescriptor", "cld", ",", "Object", "obj", ")", "{", "if", "(", "!", "ProxyHelper", ".", "isProxy", "(", "obj", ")", ")", "{", "FieldDescriptor", "fieldDescriptors", "[", "]", "=", "cld", ".", "getPkFields", "(", ")", ";", "int", "fieldDescriptorSize", "=", "fieldDescriptors", ".", "length", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "fieldDescriptorSize", ";", "i", "++", ")", "{", "FieldDescriptor", "fd", "=", "fieldDescriptors", "[", "i", "]", ";", "Object", "pkValue", "=", "fd", ".", "getPersistentField", "(", ")", ".", "get", "(", "obj", ")", ";", "if", "(", "representsNull", "(", "fd", ",", "pkValue", ")", ")", "{", "return", "false", ";", "}", "}", "}", "return", "true", ";", "}" ]
returns true if the primary key fields are valid for delete, else false. PK fields are valid if each of them contains a valid non-null value @param cld the ClassDescriptor @param obj the object @return boolean
[ "returns", "true", "if", "the", "primary", "key", "fields", "are", "valid", "for", "delete", "else", "false", ".", "PK", "fields", "are", "valid", "if", "each", "of", "them", "contains", "a", "valid", "non", "-", "null", "value" ]
9a544372f67ce965f662cdc71609dd03683c8f04
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/util/BrokerHelper.java#L475-L492
train
kuali/ojb-1.0.4
src/java/org/apache/ojb/broker/util/BrokerHelper.java
BrokerHelper.getCountQuery
public Query getCountQuery(Query aQuery) { if(aQuery instanceof QueryBySQL) { return getQueryBySqlCount((QueryBySQL) aQuery); } else if(aQuery instanceof ReportQueryByCriteria) { return getReportQueryByCriteriaCount((ReportQueryByCriteria) aQuery); } else { return getQueryByCriteriaCount((QueryByCriteria) aQuery); } }
java
public Query getCountQuery(Query aQuery) { if(aQuery instanceof QueryBySQL) { return getQueryBySqlCount((QueryBySQL) aQuery); } else if(aQuery instanceof ReportQueryByCriteria) { return getReportQueryByCriteriaCount((ReportQueryByCriteria) aQuery); } else { return getQueryByCriteriaCount((QueryByCriteria) aQuery); } }
[ "public", "Query", "getCountQuery", "(", "Query", "aQuery", ")", "{", "if", "(", "aQuery", "instanceof", "QueryBySQL", ")", "{", "return", "getQueryBySqlCount", "(", "(", "QueryBySQL", ")", "aQuery", ")", ";", "}", "else", "if", "(", "aQuery", "instanceof", "ReportQueryByCriteria", ")", "{", "return", "getReportQueryByCriteriaCount", "(", "(", "ReportQueryByCriteria", ")", "aQuery", ")", ";", "}", "else", "{", "return", "getQueryByCriteriaCount", "(", "(", "QueryByCriteria", ")", "aQuery", ")", ";", "}", "}" ]
Build a Count-Query based on aQuery @param aQuery @return The count query
[ "Build", "a", "Count", "-", "Query", "based", "on", "aQuery" ]
9a544372f67ce965f662cdc71609dd03683c8f04
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/util/BrokerHelper.java#L499-L513
train
kuali/ojb-1.0.4
src/java/org/apache/ojb/broker/util/BrokerHelper.java
BrokerHelper.getQueryBySqlCount
private Query getQueryBySqlCount(QueryBySQL aQuery) { String countSql = aQuery.getSql(); int fromPos = countSql.toUpperCase().indexOf(" FROM "); if(fromPos >= 0) { countSql = "select count(*)" + countSql.substring(fromPos); } int orderPos = countSql.toUpperCase().indexOf(" ORDER BY "); if(orderPos >= 0) { countSql = countSql.substring(0, orderPos); } return new QueryBySQL(aQuery.getSearchClass(), countSql); }
java
private Query getQueryBySqlCount(QueryBySQL aQuery) { String countSql = aQuery.getSql(); int fromPos = countSql.toUpperCase().indexOf(" FROM "); if(fromPos >= 0) { countSql = "select count(*)" + countSql.substring(fromPos); } int orderPos = countSql.toUpperCase().indexOf(" ORDER BY "); if(orderPos >= 0) { countSql = countSql.substring(0, orderPos); } return new QueryBySQL(aQuery.getSearchClass(), countSql); }
[ "private", "Query", "getQueryBySqlCount", "(", "QueryBySQL", "aQuery", ")", "{", "String", "countSql", "=", "aQuery", ".", "getSql", "(", ")", ";", "int", "fromPos", "=", "countSql", ".", "toUpperCase", "(", ")", ".", "indexOf", "(", "\" FROM \"", ")", ";", "if", "(", "fromPos", ">=", "0", ")", "{", "countSql", "=", "\"select count(*)\"", "+", "countSql", ".", "substring", "(", "fromPos", ")", ";", "}", "int", "orderPos", "=", "countSql", ".", "toUpperCase", "(", ")", ".", "indexOf", "(", "\" ORDER BY \"", ")", ";", "if", "(", "orderPos", ">=", "0", ")", "{", "countSql", "=", "countSql", ".", "substring", "(", "0", ",", "orderPos", ")", ";", "}", "return", "new", "QueryBySQL", "(", "aQuery", ".", "getSearchClass", "(", ")", ",", "countSql", ")", ";", "}" ]
Create a Count-Query for QueryBySQL @param aQuery @return The count query
[ "Create", "a", "Count", "-", "Query", "for", "QueryBySQL" ]
9a544372f67ce965f662cdc71609dd03683c8f04
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/util/BrokerHelper.java#L521-L538
train
kuali/ojb-1.0.4
src/java/org/apache/ojb/broker/util/BrokerHelper.java
BrokerHelper.getQueryByCriteriaCount
private Query getQueryByCriteriaCount(QueryByCriteria aQuery) { Class searchClass = aQuery.getSearchClass(); ReportQueryByCriteria countQuery = null; Criteria countCrit = null; String[] columns = new String[1]; // BRJ: copied Criteria without groupby, orderby, and prefetched relationships if (aQuery.getCriteria() != null) { countCrit = aQuery.getCriteria().copy(false, false, false); } if (aQuery.isDistinct()) { // BRJ: Count distinct is dbms dependent // hsql/sapdb: select count (distinct(person_id || project_id)) from person_project // mysql: select count (distinct person_id,project_id) from person_project // [tomdz] // Some databases have no support for multi-column count distinct (e.g. Derby) // Here we use a SELECT count(*) FROM (SELECT DISTINCT ...) instead // // concatenation of pk-columns is a simple way to obtain a single column // but concatenation is also dbms dependent: // // SELECT count(distinct concat(row1, row2, row3)) mysql // SELECT count(distinct (row1 || row2 || row3)) ansi // SELECT count(distinct (row1 + row2 + row3)) ms sql-server FieldDescriptor[] pkFields = m_broker.getClassDescriptor(searchClass).getPkFields(); String[] keyColumns = new String[pkFields.length]; if (pkFields.length > 1) { // TODO: Use ColumnName. This is a temporary solution because // we cannot yet resolve multiple columns in the same attribute. for (int idx = 0; idx < pkFields.length; idx++) { keyColumns[idx] = pkFields[idx].getColumnName(); } } else { for (int idx = 0; idx < pkFields.length; idx++) { keyColumns[idx] = pkFields[idx].getAttributeName(); } } // [tomdz] // TODO: Add support for databases that do not support COUNT DISTINCT over multiple columns // if (getPlatform().supportsMultiColumnCountDistinct()) // { // columns[0] = "count(distinct " + getPlatform().concatenate(keyColumns) + ")"; // } // else // { // columns = keyColumns; // } columns[0] = "count(distinct " + getPlatform().concatenate(keyColumns) + ")"; } else { columns[0] = "count(*)"; } // BRJ: we have to preserve indirection table ! if (aQuery instanceof MtoNQuery) { MtoNQuery mnQuery = (MtoNQuery)aQuery; ReportQueryByMtoNCriteria mnReportQuery = new ReportQueryByMtoNCriteria(searchClass, columns, countCrit); mnReportQuery.setIndirectionTable(mnQuery.getIndirectionTable()); countQuery = mnReportQuery; } else { countQuery = new ReportQueryByCriteria(searchClass, columns, countCrit); } // BRJ: we have to preserve outer-join-settings (by André Markwalder) for (Iterator outerJoinPath = aQuery.getOuterJoinPaths().iterator(); outerJoinPath.hasNext();) { String path = (String) outerJoinPath.next(); if (aQuery.isPathOuterJoin(path)) { countQuery.setPathOuterJoin(path); } } //BRJ: add orderBy Columns asJoinAttributes List orderBy = aQuery.getOrderBy(); if ((orderBy != null) && !orderBy.isEmpty()) { String[] joinAttributes = new String[orderBy.size()]; for (int idx = 0; idx < orderBy.size(); idx++) { joinAttributes[idx] = ((FieldHelper)orderBy.get(idx)).name; } countQuery.setJoinAttributes(joinAttributes); } // [tomdz] // TODO: // For those databases that do not support COUNT DISTINCT over multiple columns // we wrap the normal SELECT DISTINCT that we just created, into a SELECT count(*) // For this however we need a report query that gets its data from a sub query instead // of a table (target class) // if (aQuery.isDistinct() && !getPlatform().supportsMultiColumnCountDistinct()) // { // } return countQuery; }
java
private Query getQueryByCriteriaCount(QueryByCriteria aQuery) { Class searchClass = aQuery.getSearchClass(); ReportQueryByCriteria countQuery = null; Criteria countCrit = null; String[] columns = new String[1]; // BRJ: copied Criteria without groupby, orderby, and prefetched relationships if (aQuery.getCriteria() != null) { countCrit = aQuery.getCriteria().copy(false, false, false); } if (aQuery.isDistinct()) { // BRJ: Count distinct is dbms dependent // hsql/sapdb: select count (distinct(person_id || project_id)) from person_project // mysql: select count (distinct person_id,project_id) from person_project // [tomdz] // Some databases have no support for multi-column count distinct (e.g. Derby) // Here we use a SELECT count(*) FROM (SELECT DISTINCT ...) instead // // concatenation of pk-columns is a simple way to obtain a single column // but concatenation is also dbms dependent: // // SELECT count(distinct concat(row1, row2, row3)) mysql // SELECT count(distinct (row1 || row2 || row3)) ansi // SELECT count(distinct (row1 + row2 + row3)) ms sql-server FieldDescriptor[] pkFields = m_broker.getClassDescriptor(searchClass).getPkFields(); String[] keyColumns = new String[pkFields.length]; if (pkFields.length > 1) { // TODO: Use ColumnName. This is a temporary solution because // we cannot yet resolve multiple columns in the same attribute. for (int idx = 0; idx < pkFields.length; idx++) { keyColumns[idx] = pkFields[idx].getColumnName(); } } else { for (int idx = 0; idx < pkFields.length; idx++) { keyColumns[idx] = pkFields[idx].getAttributeName(); } } // [tomdz] // TODO: Add support for databases that do not support COUNT DISTINCT over multiple columns // if (getPlatform().supportsMultiColumnCountDistinct()) // { // columns[0] = "count(distinct " + getPlatform().concatenate(keyColumns) + ")"; // } // else // { // columns = keyColumns; // } columns[0] = "count(distinct " + getPlatform().concatenate(keyColumns) + ")"; } else { columns[0] = "count(*)"; } // BRJ: we have to preserve indirection table ! if (aQuery instanceof MtoNQuery) { MtoNQuery mnQuery = (MtoNQuery)aQuery; ReportQueryByMtoNCriteria mnReportQuery = new ReportQueryByMtoNCriteria(searchClass, columns, countCrit); mnReportQuery.setIndirectionTable(mnQuery.getIndirectionTable()); countQuery = mnReportQuery; } else { countQuery = new ReportQueryByCriteria(searchClass, columns, countCrit); } // BRJ: we have to preserve outer-join-settings (by André Markwalder) for (Iterator outerJoinPath = aQuery.getOuterJoinPaths().iterator(); outerJoinPath.hasNext();) { String path = (String) outerJoinPath.next(); if (aQuery.isPathOuterJoin(path)) { countQuery.setPathOuterJoin(path); } } //BRJ: add orderBy Columns asJoinAttributes List orderBy = aQuery.getOrderBy(); if ((orderBy != null) && !orderBy.isEmpty()) { String[] joinAttributes = new String[orderBy.size()]; for (int idx = 0; idx < orderBy.size(); idx++) { joinAttributes[idx] = ((FieldHelper)orderBy.get(idx)).name; } countQuery.setJoinAttributes(joinAttributes); } // [tomdz] // TODO: // For those databases that do not support COUNT DISTINCT over multiple columns // we wrap the normal SELECT DISTINCT that we just created, into a SELECT count(*) // For this however we need a report query that gets its data from a sub query instead // of a table (target class) // if (aQuery.isDistinct() && !getPlatform().supportsMultiColumnCountDistinct()) // { // } return countQuery; }
[ "private", "Query", "getQueryByCriteriaCount", "(", "QueryByCriteria", "aQuery", ")", "{", "Class", "searchClass", "=", "aQuery", ".", "getSearchClass", "(", ")", ";", "ReportQueryByCriteria", "countQuery", "=", "null", ";", "Criteria", "countCrit", "=", "null", ";", "String", "[", "]", "columns", "=", "new", "String", "[", "1", "]", ";", "// BRJ: copied Criteria without groupby, orderby, and prefetched relationships\r", "if", "(", "aQuery", ".", "getCriteria", "(", ")", "!=", "null", ")", "{", "countCrit", "=", "aQuery", ".", "getCriteria", "(", ")", ".", "copy", "(", "false", ",", "false", ",", "false", ")", ";", "}", "if", "(", "aQuery", ".", "isDistinct", "(", ")", ")", "{", "// BRJ: Count distinct is dbms dependent\r", "// hsql/sapdb: select count (distinct(person_id || project_id)) from person_project\r", "// mysql: select count (distinct person_id,project_id) from person_project\r", "// [tomdz]\r", "// Some databases have no support for multi-column count distinct (e.g. Derby)\r", "// Here we use a SELECT count(*) FROM (SELECT DISTINCT ...) instead \r", "//\r", "// concatenation of pk-columns is a simple way to obtain a single column\r", "// but concatenation is also dbms dependent:\r", "//\r", "// SELECT count(distinct concat(row1, row2, row3)) mysql\r", "// SELECT count(distinct (row1 || row2 || row3)) ansi\r", "// SELECT count(distinct (row1 + row2 + row3)) ms sql-server\r", "FieldDescriptor", "[", "]", "pkFields", "=", "m_broker", ".", "getClassDescriptor", "(", "searchClass", ")", ".", "getPkFields", "(", ")", ";", "String", "[", "]", "keyColumns", "=", "new", "String", "[", "pkFields", ".", "length", "]", ";", "if", "(", "pkFields", ".", "length", ">", "1", ")", "{", "// TODO: Use ColumnName. This is a temporary solution because\r", "// we cannot yet resolve multiple columns in the same attribute.\r", "for", "(", "int", "idx", "=", "0", ";", "idx", "<", "pkFields", ".", "length", ";", "idx", "++", ")", "{", "keyColumns", "[", "idx", "]", "=", "pkFields", "[", "idx", "]", ".", "getColumnName", "(", ")", ";", "}", "}", "else", "{", "for", "(", "int", "idx", "=", "0", ";", "idx", "<", "pkFields", ".", "length", ";", "idx", "++", ")", "{", "keyColumns", "[", "idx", "]", "=", "pkFields", "[", "idx", "]", ".", "getAttributeName", "(", ")", ";", "}", "}", "// [tomdz]\r", "// TODO: Add support for databases that do not support COUNT DISTINCT over multiple columns\r", "// if (getPlatform().supportsMultiColumnCountDistinct())\r", "// {\r", "// columns[0] = \"count(distinct \" + getPlatform().concatenate(keyColumns) + \")\";\r", "// }\r", "// else\r", "// {\r", "// columns = keyColumns;\r", "// }\r", "columns", "[", "0", "]", "=", "\"count(distinct \"", "+", "getPlatform", "(", ")", ".", "concatenate", "(", "keyColumns", ")", "+", "\")\"", ";", "}", "else", "{", "columns", "[", "0", "]", "=", "\"count(*)\"", ";", "}", "// BRJ: we have to preserve indirection table !\r", "if", "(", "aQuery", "instanceof", "MtoNQuery", ")", "{", "MtoNQuery", "mnQuery", "=", "(", "MtoNQuery", ")", "aQuery", ";", "ReportQueryByMtoNCriteria", "mnReportQuery", "=", "new", "ReportQueryByMtoNCriteria", "(", "searchClass", ",", "columns", ",", "countCrit", ")", ";", "mnReportQuery", ".", "setIndirectionTable", "(", "mnQuery", ".", "getIndirectionTable", "(", ")", ")", ";", "countQuery", "=", "mnReportQuery", ";", "}", "else", "{", "countQuery", "=", "new", "ReportQueryByCriteria", "(", "searchClass", ",", "columns", ",", "countCrit", ")", ";", "}", "// BRJ: we have to preserve outer-join-settings (by André Markwalder)\r", "for", "(", "Iterator", "outerJoinPath", "=", "aQuery", ".", "getOuterJoinPaths", "(", ")", ".", "iterator", "(", ")", ";", "outerJoinPath", ".", "hasNext", "(", ")", ";", ")", "{", "String", "path", "=", "(", "String", ")", "outerJoinPath", ".", "next", "(", ")", ";", "if", "(", "aQuery", ".", "isPathOuterJoin", "(", "path", ")", ")", "{", "countQuery", ".", "setPathOuterJoin", "(", "path", ")", ";", "}", "}", "//BRJ: add orderBy Columns asJoinAttributes\r", "List", "orderBy", "=", "aQuery", ".", "getOrderBy", "(", ")", ";", "if", "(", "(", "orderBy", "!=", "null", ")", "&&", "!", "orderBy", ".", "isEmpty", "(", ")", ")", "{", "String", "[", "]", "joinAttributes", "=", "new", "String", "[", "orderBy", ".", "size", "(", ")", "]", ";", "for", "(", "int", "idx", "=", "0", ";", "idx", "<", "orderBy", ".", "size", "(", ")", ";", "idx", "++", ")", "{", "joinAttributes", "[", "idx", "]", "=", "(", "(", "FieldHelper", ")", "orderBy", ".", "get", "(", "idx", ")", ")", ".", "name", ";", "}", "countQuery", ".", "setJoinAttributes", "(", "joinAttributes", ")", ";", "}", "// [tomdz]\r", "// TODO:\r", "// For those databases that do not support COUNT DISTINCT over multiple columns\r", "// we wrap the normal SELECT DISTINCT that we just created, into a SELECT count(*)\r", "// For this however we need a report query that gets its data from a sub query instead\r", "// of a table (target class)\r", "// if (aQuery.isDistinct() && !getPlatform().supportsMultiColumnCountDistinct())\r", "// {\r", "// }\r", "return", "countQuery", ";", "}" ]
Create a Count-Query for QueryByCriteria
[ "Create", "a", "Count", "-", "Query", "for", "QueryByCriteria" ]
9a544372f67ce965f662cdc71609dd03683c8f04
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/util/BrokerHelper.java#L543-L659
train
kuali/ojb-1.0.4
src/java/org/apache/ojb/broker/util/BrokerHelper.java
BrokerHelper.getReportQueryByCriteriaCount
private Query getReportQueryByCriteriaCount(ReportQueryByCriteria aQuery) { ReportQueryByCriteria countQuery = (ReportQueryByCriteria) getQueryByCriteriaCount(aQuery); // BRJ: keep the original columns to build the Join countQuery.setJoinAttributes(aQuery.getAttributes()); // BRJ: we have to preserve groupby information Iterator iter = aQuery.getGroupBy().iterator(); while(iter.hasNext()) { countQuery.addGroupBy((FieldHelper) iter.next()); } return countQuery; }
java
private Query getReportQueryByCriteriaCount(ReportQueryByCriteria aQuery) { ReportQueryByCriteria countQuery = (ReportQueryByCriteria) getQueryByCriteriaCount(aQuery); // BRJ: keep the original columns to build the Join countQuery.setJoinAttributes(aQuery.getAttributes()); // BRJ: we have to preserve groupby information Iterator iter = aQuery.getGroupBy().iterator(); while(iter.hasNext()) { countQuery.addGroupBy((FieldHelper) iter.next()); } return countQuery; }
[ "private", "Query", "getReportQueryByCriteriaCount", "(", "ReportQueryByCriteria", "aQuery", ")", "{", "ReportQueryByCriteria", "countQuery", "=", "(", "ReportQueryByCriteria", ")", "getQueryByCriteriaCount", "(", "aQuery", ")", ";", "// BRJ: keep the original columns to build the Join\r", "countQuery", ".", "setJoinAttributes", "(", "aQuery", ".", "getAttributes", "(", ")", ")", ";", "// BRJ: we have to preserve groupby information\r", "Iterator", "iter", "=", "aQuery", ".", "getGroupBy", "(", ")", ".", "iterator", "(", ")", ";", "while", "(", "iter", ".", "hasNext", "(", ")", ")", "{", "countQuery", ".", "addGroupBy", "(", "(", "FieldHelper", ")", "iter", ".", "next", "(", ")", ")", ";", "}", "return", "countQuery", ";", "}" ]
Create a Count-Query for ReportQueryByCriteria
[ "Create", "a", "Count", "-", "Query", "for", "ReportQueryByCriteria" ]
9a544372f67ce965f662cdc71609dd03683c8f04
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/util/BrokerHelper.java#L664-L679
train
kuali/ojb-1.0.4
src/java/org/apache/ojb/broker/util/BrokerHelper.java
BrokerHelper.unlink
public boolean unlink(Object source, String attributeName, Object target) { return linkOrUnlink(false, source, attributeName, false); }
java
public boolean unlink(Object source, String attributeName, Object target) { return linkOrUnlink(false, source, attributeName, false); }
[ "public", "boolean", "unlink", "(", "Object", "source", ",", "String", "attributeName", ",", "Object", "target", ")", "{", "return", "linkOrUnlink", "(", "false", ",", "source", ",", "attributeName", ",", "false", ")", ";", "}" ]
Unlink the specified reference object. More info see OJB doc. @param source The source object with the specified reference field. @param attributeName The field name of the reference to unlink. @param target The referenced object to unlink.
[ "Unlink", "the", "specified", "reference", "object", ".", "More", "info", "see", "OJB", "doc", "." ]
9a544372f67ce965f662cdc71609dd03683c8f04
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/util/BrokerHelper.java#L876-L879
train
kuali/ojb-1.0.4
src/java/org/apache/ojb/broker/util/BrokerHelper.java
BrokerHelper.unlink
public void unlink(Object obj, ObjectReferenceDescriptor ord, boolean insert) { linkOrUnlink(false, obj, ord, insert); }
java
public void unlink(Object obj, ObjectReferenceDescriptor ord, boolean insert) { linkOrUnlink(false, obj, ord, insert); }
[ "public", "void", "unlink", "(", "Object", "obj", ",", "ObjectReferenceDescriptor", "ord", ",", "boolean", "insert", ")", "{", "linkOrUnlink", "(", "false", ",", "obj", ",", "ord", ",", "insert", ")", ";", "}" ]
Unlink the specified reference from this object. More info see OJB doc. @param obj Object with reference @param ord the ObjectReferenceDescriptor of the reference @param insert flag signals insert operation
[ "Unlink", "the", "specified", "reference", "from", "this", "object", ".", "More", "info", "see", "OJB", "doc", "." ]
9a544372f67ce965f662cdc71609dd03683c8f04
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/util/BrokerHelper.java#L900-L903
train
kuali/ojb-1.0.4
src/tools/org/apache/ojb/tools/mapping/reversedb2/dbmetatreemodel/DBMetaCatalogNode.java
DBMetaCatalogNode._load
protected boolean _load () { java.sql.ResultSet rs = null; try { // This synchronization is necessary for Oracle JDBC drivers 8.1.7, 9.0.1, 9.2.0.1 // The documentation says synchronization is done within the driver, but they // must have overlooked something. Without the lock we'd get mysterious error // messages. synchronized(getDbMeta()) { getDbMetaTreeModel().setStatusBarMessage("Reading schemas for catalog " + this.getAttribute(ATT_CATALOG_NAME)); rs = getDbMeta().getSchemas(); final java.util.ArrayList alNew = new java.util.ArrayList(); int count = 0; while (rs.next()) { getDbMetaTreeModel().setStatusBarMessage("Creating schema " + getCatalogName() + "." + rs.getString("TABLE_SCHEM")); alNew.add(new DBMetaSchemaNode(getDbMeta(), getDbMetaTreeModel(), DBMetaCatalogNode.this, rs.getString("TABLE_SCHEM"))); count++; } if (count == 0) alNew.add(new DBMetaSchemaNode(getDbMeta(), getDbMetaTreeModel(), DBMetaCatalogNode.this, null)); alChildren = alNew; javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { getDbMetaTreeModel().nodeStructureChanged(DBMetaCatalogNode.this); } }); rs.close(); } } catch (java.sql.SQLException sqlEx) { getDbMetaTreeModel().reportSqlError("Error retrieving schemas", sqlEx); try { if (rs != null) rs.close (); } catch (java.sql.SQLException sqlEx2) { this.getDbMetaTreeModel().reportSqlError("Error retrieving schemas", sqlEx2); } return false; } return true; }
java
protected boolean _load () { java.sql.ResultSet rs = null; try { // This synchronization is necessary for Oracle JDBC drivers 8.1.7, 9.0.1, 9.2.0.1 // The documentation says synchronization is done within the driver, but they // must have overlooked something. Without the lock we'd get mysterious error // messages. synchronized(getDbMeta()) { getDbMetaTreeModel().setStatusBarMessage("Reading schemas for catalog " + this.getAttribute(ATT_CATALOG_NAME)); rs = getDbMeta().getSchemas(); final java.util.ArrayList alNew = new java.util.ArrayList(); int count = 0; while (rs.next()) { getDbMetaTreeModel().setStatusBarMessage("Creating schema " + getCatalogName() + "." + rs.getString("TABLE_SCHEM")); alNew.add(new DBMetaSchemaNode(getDbMeta(), getDbMetaTreeModel(), DBMetaCatalogNode.this, rs.getString("TABLE_SCHEM"))); count++; } if (count == 0) alNew.add(new DBMetaSchemaNode(getDbMeta(), getDbMetaTreeModel(), DBMetaCatalogNode.this, null)); alChildren = alNew; javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { getDbMetaTreeModel().nodeStructureChanged(DBMetaCatalogNode.this); } }); rs.close(); } } catch (java.sql.SQLException sqlEx) { getDbMetaTreeModel().reportSqlError("Error retrieving schemas", sqlEx); try { if (rs != null) rs.close (); } catch (java.sql.SQLException sqlEx2) { this.getDbMetaTreeModel().reportSqlError("Error retrieving schemas", sqlEx2); } return false; } return true; }
[ "protected", "boolean", "_load", "(", ")", "{", "java", ".", "sql", ".", "ResultSet", "rs", "=", "null", ";", "try", "{", "// This synchronization is necessary for Oracle JDBC drivers 8.1.7, 9.0.1, 9.2.0.1\r", "// The documentation says synchronization is done within the driver, but they\r", "// must have overlooked something. Without the lock we'd get mysterious error\r", "// messages. \r", "synchronized", "(", "getDbMeta", "(", ")", ")", "{", "getDbMetaTreeModel", "(", ")", ".", "setStatusBarMessage", "(", "\"Reading schemas for catalog \"", "+", "this", ".", "getAttribute", "(", "ATT_CATALOG_NAME", ")", ")", ";", "rs", "=", "getDbMeta", "(", ")", ".", "getSchemas", "(", ")", ";", "final", "java", ".", "util", ".", "ArrayList", "alNew", "=", "new", "java", ".", "util", ".", "ArrayList", "(", ")", ";", "int", "count", "=", "0", ";", "while", "(", "rs", ".", "next", "(", ")", ")", "{", "getDbMetaTreeModel", "(", ")", ".", "setStatusBarMessage", "(", "\"Creating schema \"", "+", "getCatalogName", "(", ")", "+", "\".\"", "+", "rs", ".", "getString", "(", "\"TABLE_SCHEM\"", ")", ")", ";", "alNew", ".", "add", "(", "new", "DBMetaSchemaNode", "(", "getDbMeta", "(", ")", ",", "getDbMetaTreeModel", "(", ")", ",", "DBMetaCatalogNode", ".", "this", ",", "rs", ".", "getString", "(", "\"TABLE_SCHEM\"", ")", ")", ")", ";", "count", "++", ";", "}", "if", "(", "count", "==", "0", ")", "alNew", ".", "add", "(", "new", "DBMetaSchemaNode", "(", "getDbMeta", "(", ")", ",", "getDbMetaTreeModel", "(", ")", ",", "DBMetaCatalogNode", ".", "this", ",", "null", ")", ")", ";", "alChildren", "=", "alNew", ";", "javax", ".", "swing", ".", "SwingUtilities", ".", "invokeLater", "(", "new", "Runnable", "(", ")", "{", "public", "void", "run", "(", ")", "{", "getDbMetaTreeModel", "(", ")", ".", "nodeStructureChanged", "(", "DBMetaCatalogNode", ".", "this", ")", ";", "}", "}", ")", ";", "rs", ".", "close", "(", ")", ";", "}", "}", "catch", "(", "java", ".", "sql", ".", "SQLException", "sqlEx", ")", "{", "getDbMetaTreeModel", "(", ")", ".", "reportSqlError", "(", "\"Error retrieving schemas\"", ",", "sqlEx", ")", ";", "try", "{", "if", "(", "rs", "!=", "null", ")", "rs", ".", "close", "(", ")", ";", "}", "catch", "(", "java", ".", "sql", ".", "SQLException", "sqlEx2", ")", "{", "this", ".", "getDbMetaTreeModel", "(", ")", ".", "reportSqlError", "(", "\"Error retrieving schemas\"", ",", "sqlEx2", ")", ";", "}", "return", "false", ";", "}", "return", "true", ";", "}" ]
Loads the schemas associated to this catalog.
[ "Loads", "the", "schemas", "associated", "to", "this", "catalog", "." ]
9a544372f67ce965f662cdc71609dd03683c8f04
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/tools/org/apache/ojb/tools/mapping/reversedb2/dbmetatreemodel/DBMetaCatalogNode.java#L93-L149
train
kuali/ojb-1.0.4
src/java/org/apache/ojb/broker/metadata/ConnectionRepository.java
ConnectionRepository.removeDescriptor
public void removeDescriptor(Object validKey) { PBKey pbKey; if (validKey instanceof PBKey) { pbKey = (PBKey) validKey; } else if (validKey instanceof JdbcConnectionDescriptor) { pbKey = ((JdbcConnectionDescriptor) validKey).getPBKey(); } else { throw new MetadataException("Could not remove descriptor, given object was no vaild key: " + validKey); } Object removed = null; synchronized (jcdMap) { removed = jcdMap.remove(pbKey); jcdAliasToPBKeyMap.remove(pbKey.getAlias()); } log.info("Remove descriptor: " + removed); }
java
public void removeDescriptor(Object validKey) { PBKey pbKey; if (validKey instanceof PBKey) { pbKey = (PBKey) validKey; } else if (validKey instanceof JdbcConnectionDescriptor) { pbKey = ((JdbcConnectionDescriptor) validKey).getPBKey(); } else { throw new MetadataException("Could not remove descriptor, given object was no vaild key: " + validKey); } Object removed = null; synchronized (jcdMap) { removed = jcdMap.remove(pbKey); jcdAliasToPBKeyMap.remove(pbKey.getAlias()); } log.info("Remove descriptor: " + removed); }
[ "public", "void", "removeDescriptor", "(", "Object", "validKey", ")", "{", "PBKey", "pbKey", ";", "if", "(", "validKey", "instanceof", "PBKey", ")", "{", "pbKey", "=", "(", "PBKey", ")", "validKey", ";", "}", "else", "if", "(", "validKey", "instanceof", "JdbcConnectionDescriptor", ")", "{", "pbKey", "=", "(", "(", "JdbcConnectionDescriptor", ")", "validKey", ")", ".", "getPBKey", "(", ")", ";", "}", "else", "{", "throw", "new", "MetadataException", "(", "\"Could not remove descriptor, given object was no vaild key: \"", "+", "validKey", ")", ";", "}", "Object", "removed", "=", "null", ";", "synchronized", "(", "jcdMap", ")", "{", "removed", "=", "jcdMap", ".", "remove", "(", "pbKey", ")", ";", "jcdAliasToPBKeyMap", ".", "remove", "(", "pbKey", ".", "getAlias", "(", ")", ")", ";", "}", "log", ".", "info", "(", "\"Remove descriptor: \"", "+", "removed", ")", ";", "}" ]
Remove a descriptor. @param validKey This could be the {@link JdbcConnectionDescriptor} itself, or the associated {@link JdbcConnectionDescriptor#getPBKey PBKey}.
[ "Remove", "a", "descriptor", "." ]
9a544372f67ce965f662cdc71609dd03683c8f04
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/metadata/ConnectionRepository.java#L226-L249
train
kuali/ojb-1.0.4
src/java/org/apache/ojb/broker/core/IdentityFactoryImpl.java
IdentityFactoryImpl.findIndexForName
private int findIndexForName(String[] fieldNames, String searchName) { for(int i = 0; i < fieldNames.length; i++) { if(searchName.equals(fieldNames[i])) { return i; } } throw new PersistenceBrokerException("Can't find field name '" + searchName + "' in given array of field names"); }
java
private int findIndexForName(String[] fieldNames, String searchName) { for(int i = 0; i < fieldNames.length; i++) { if(searchName.equals(fieldNames[i])) { return i; } } throw new PersistenceBrokerException("Can't find field name '" + searchName + "' in given array of field names"); }
[ "private", "int", "findIndexForName", "(", "String", "[", "]", "fieldNames", ",", "String", "searchName", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "fieldNames", ".", "length", ";", "i", "++", ")", "{", "if", "(", "searchName", ".", "equals", "(", "fieldNames", "[", "i", "]", ")", ")", "{", "return", "i", ";", "}", "}", "throw", "new", "PersistenceBrokerException", "(", "\"Can't find field name '\"", "+", "searchName", "+", "\"' in given array of field names\"", ")", ";", "}" ]
Find the index of the specified name in field name array.
[ "Find", "the", "index", "of", "the", "specified", "name", "in", "field", "name", "array", "." ]
9a544372f67ce965f662cdc71609dd03683c8f04
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/core/IdentityFactoryImpl.java#L203-L214
train
kuali/ojb-1.0.4
src/java/org/apache/ojb/broker/core/IdentityFactoryImpl.java
IdentityFactoryImpl.isOrdered
private boolean isOrdered(FieldDescriptor[] flds, String[] pkFieldNames) { if((flds.length > 1 && pkFieldNames == null) || flds.length != pkFieldNames.length) { throw new PersistenceBrokerException("pkFieldName length does not match number of defined PK fields." + " Expected number of PK fields is " + flds.length + ", given number was " + (pkFieldNames != null ? pkFieldNames.length : 0)); } boolean result = true; for(int i = 0; i < flds.length; i++) { FieldDescriptor fld = flds[i]; result = result && fld.getPersistentField().getName().equals(pkFieldNames[i]); } return result; }
java
private boolean isOrdered(FieldDescriptor[] flds, String[] pkFieldNames) { if((flds.length > 1 && pkFieldNames == null) || flds.length != pkFieldNames.length) { throw new PersistenceBrokerException("pkFieldName length does not match number of defined PK fields." + " Expected number of PK fields is " + flds.length + ", given number was " + (pkFieldNames != null ? pkFieldNames.length : 0)); } boolean result = true; for(int i = 0; i < flds.length; i++) { FieldDescriptor fld = flds[i]; result = result && fld.getPersistentField().getName().equals(pkFieldNames[i]); } return result; }
[ "private", "boolean", "isOrdered", "(", "FieldDescriptor", "[", "]", "flds", ",", "String", "[", "]", "pkFieldNames", ")", "{", "if", "(", "(", "flds", ".", "length", ">", "1", "&&", "pkFieldNames", "==", "null", ")", "||", "flds", ".", "length", "!=", "pkFieldNames", ".", "length", ")", "{", "throw", "new", "PersistenceBrokerException", "(", "\"pkFieldName length does not match number of defined PK fields.\"", "+", "\" Expected number of PK fields is \"", "+", "flds", ".", "length", "+", "\", given number was \"", "+", "(", "pkFieldNames", "!=", "null", "?", "pkFieldNames", ".", "length", ":", "0", ")", ")", ";", "}", "boolean", "result", "=", "true", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "flds", ".", "length", ";", "i", "++", ")", "{", "FieldDescriptor", "fld", "=", "flds", "[", "i", "]", ";", "result", "=", "result", "&&", "fld", ".", "getPersistentField", "(", ")", ".", "getName", "(", ")", ".", "equals", "(", "pkFieldNames", "[", "i", "]", ")", ";", "}", "return", "result", ";", "}" ]
Checks length and compare order of field names with declared PK fields in metadata.
[ "Checks", "length", "and", "compare", "order", "of", "field", "names", "with", "declared", "PK", "fields", "in", "metadata", "." ]
9a544372f67ce965f662cdc71609dd03683c8f04
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/core/IdentityFactoryImpl.java#L217-L232
train
kuali/ojb-1.0.4
src/java/org/apache/ojb/broker/core/IdentityFactoryImpl.java
IdentityFactoryImpl.createException
private PersistenceBrokerException createException(final Exception ex, String message, final Object objectToIdentify, Class topLevelClass, Class realClass, Object[] pks) { final String eol = SystemUtils.LINE_SEPARATOR; StringBuffer msg = new StringBuffer(); if(message == null) { msg.append("Unexpected error: "); } else { msg.append(message).append(" :"); } if(topLevelClass != null) msg.append(eol).append("objectTopLevelClass=").append(topLevelClass.getName()); if(realClass != null) msg.append(eol).append("objectRealClass=").append(realClass.getName()); if(pks != null) msg.append(eol).append("pkValues=").append(ArrayUtils.toString(pks)); if(objectToIdentify != null) msg.append(eol).append("object to identify: ").append(objectToIdentify); if(ex != null) { // add causing stack trace Throwable rootCause = ExceptionUtils.getRootCause(ex); if(rootCause != null) { msg.append(eol).append("The root stack trace is --> "); String rootStack = ExceptionUtils.getStackTrace(rootCause); msg.append(eol).append(rootStack); } return new PersistenceBrokerException(msg.toString(), ex); } else { return new PersistenceBrokerException(msg.toString()); } }
java
private PersistenceBrokerException createException(final Exception ex, String message, final Object objectToIdentify, Class topLevelClass, Class realClass, Object[] pks) { final String eol = SystemUtils.LINE_SEPARATOR; StringBuffer msg = new StringBuffer(); if(message == null) { msg.append("Unexpected error: "); } else { msg.append(message).append(" :"); } if(topLevelClass != null) msg.append(eol).append("objectTopLevelClass=").append(topLevelClass.getName()); if(realClass != null) msg.append(eol).append("objectRealClass=").append(realClass.getName()); if(pks != null) msg.append(eol).append("pkValues=").append(ArrayUtils.toString(pks)); if(objectToIdentify != null) msg.append(eol).append("object to identify: ").append(objectToIdentify); if(ex != null) { // add causing stack trace Throwable rootCause = ExceptionUtils.getRootCause(ex); if(rootCause != null) { msg.append(eol).append("The root stack trace is --> "); String rootStack = ExceptionUtils.getStackTrace(rootCause); msg.append(eol).append(rootStack); } return new PersistenceBrokerException(msg.toString(), ex); } else { return new PersistenceBrokerException(msg.toString()); } }
[ "private", "PersistenceBrokerException", "createException", "(", "final", "Exception", "ex", ",", "String", "message", ",", "final", "Object", "objectToIdentify", ",", "Class", "topLevelClass", ",", "Class", "realClass", ",", "Object", "[", "]", "pks", ")", "{", "final", "String", "eol", "=", "SystemUtils", ".", "LINE_SEPARATOR", ";", "StringBuffer", "msg", "=", "new", "StringBuffer", "(", ")", ";", "if", "(", "message", "==", "null", ")", "{", "msg", ".", "append", "(", "\"Unexpected error: \"", ")", ";", "}", "else", "{", "msg", ".", "append", "(", "message", ")", ".", "append", "(", "\" :\"", ")", ";", "}", "if", "(", "topLevelClass", "!=", "null", ")", "msg", ".", "append", "(", "eol", ")", ".", "append", "(", "\"objectTopLevelClass=\"", ")", ".", "append", "(", "topLevelClass", ".", "getName", "(", ")", ")", ";", "if", "(", "realClass", "!=", "null", ")", "msg", ".", "append", "(", "eol", ")", ".", "append", "(", "\"objectRealClass=\"", ")", ".", "append", "(", "realClass", ".", "getName", "(", ")", ")", ";", "if", "(", "pks", "!=", "null", ")", "msg", ".", "append", "(", "eol", ")", ".", "append", "(", "\"pkValues=\"", ")", ".", "append", "(", "ArrayUtils", ".", "toString", "(", "pks", ")", ")", ";", "if", "(", "objectToIdentify", "!=", "null", ")", "msg", ".", "append", "(", "eol", ")", ".", "append", "(", "\"object to identify: \"", ")", ".", "append", "(", "objectToIdentify", ")", ";", "if", "(", "ex", "!=", "null", ")", "{", "// add causing stack trace\r", "Throwable", "rootCause", "=", "ExceptionUtils", ".", "getRootCause", "(", "ex", ")", ";", "if", "(", "rootCause", "!=", "null", ")", "{", "msg", ".", "append", "(", "eol", ")", ".", "append", "(", "\"The root stack trace is --> \"", ")", ";", "String", "rootStack", "=", "ExceptionUtils", ".", "getStackTrace", "(", "rootCause", ")", ";", "msg", ".", "append", "(", "eol", ")", ".", "append", "(", "rootStack", ")", ";", "}", "return", "new", "PersistenceBrokerException", "(", "msg", ".", "toString", "(", ")", ",", "ex", ")", ";", "}", "else", "{", "return", "new", "PersistenceBrokerException", "(", "msg", ".", "toString", "(", ")", ")", ";", "}", "}" ]
Helper method which supports creation of proper error messages. @param ex An exception to include or <em>null</em>. @param message The error message or <em>null</em>. @param objectToIdentify The current used object or <em>null</em>. @param topLevelClass The object top-level class or <em>null</em>. @param realClass The object real class or <em>null</em>. @param pks The associated PK values of the object or <em>null</em>. @return The generated exception.
[ "Helper", "method", "which", "supports", "creation", "of", "proper", "error", "messages", "." ]
9a544372f67ce965f662cdc71609dd03683c8f04
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/core/IdentityFactoryImpl.java#L263-L296
train
kuali/ojb-1.0.4
src/java/org/apache/ojb/odmg/ObjectEnvelopeOrdering.java
ObjectEnvelopeOrdering.addEdgesForVertex
private void addEdgesForVertex(Vertex vertex) { ClassDescriptor cld = vertex.getEnvelope().getClassDescriptor(); Iterator rdsIter = cld.getObjectReferenceDescriptors(true).iterator(); while (rdsIter.hasNext()) { ObjectReferenceDescriptor rds = (ObjectReferenceDescriptor) rdsIter.next(); addObjectReferenceEdges(vertex, rds); } Iterator cdsIter = cld.getCollectionDescriptors(true).iterator(); while (cdsIter.hasNext()) { CollectionDescriptor cds = (CollectionDescriptor) cdsIter.next(); addCollectionEdges(vertex, cds); } }
java
private void addEdgesForVertex(Vertex vertex) { ClassDescriptor cld = vertex.getEnvelope().getClassDescriptor(); Iterator rdsIter = cld.getObjectReferenceDescriptors(true).iterator(); while (rdsIter.hasNext()) { ObjectReferenceDescriptor rds = (ObjectReferenceDescriptor) rdsIter.next(); addObjectReferenceEdges(vertex, rds); } Iterator cdsIter = cld.getCollectionDescriptors(true).iterator(); while (cdsIter.hasNext()) { CollectionDescriptor cds = (CollectionDescriptor) cdsIter.next(); addCollectionEdges(vertex, cds); } }
[ "private", "void", "addEdgesForVertex", "(", "Vertex", "vertex", ")", "{", "ClassDescriptor", "cld", "=", "vertex", ".", "getEnvelope", "(", ")", ".", "getClassDescriptor", "(", ")", ";", "Iterator", "rdsIter", "=", "cld", ".", "getObjectReferenceDescriptors", "(", "true", ")", ".", "iterator", "(", ")", ";", "while", "(", "rdsIter", ".", "hasNext", "(", ")", ")", "{", "ObjectReferenceDescriptor", "rds", "=", "(", "ObjectReferenceDescriptor", ")", "rdsIter", ".", "next", "(", ")", ";", "addObjectReferenceEdges", "(", "vertex", ",", "rds", ")", ";", "}", "Iterator", "cdsIter", "=", "cld", ".", "getCollectionDescriptors", "(", "true", ")", ".", "iterator", "(", ")", ";", "while", "(", "cdsIter", ".", "hasNext", "(", ")", ")", "{", "CollectionDescriptor", "cds", "=", "(", "CollectionDescriptor", ")", "cdsIter", ".", "next", "(", ")", ";", "addCollectionEdges", "(", "vertex", ",", "cds", ")", ";", "}", "}" ]
Adds all edges for a given object envelope vertex. All edges are added to the edgeList map. @param vertex the Vertex object to find edges for
[ "Adds", "all", "edges", "for", "a", "given", "object", "envelope", "vertex", ".", "All", "edges", "are", "added", "to", "the", "edgeList", "map", "." ]
9a544372f67ce965f662cdc71609dd03683c8f04
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/odmg/ObjectEnvelopeOrdering.java#L261-L276
train
kuali/ojb-1.0.4
src/java/org/apache/ojb/odmg/ObjectEnvelopeOrdering.java
ObjectEnvelopeOrdering.addObjectReferenceEdges
private void addObjectReferenceEdges(Vertex vertex, ObjectReferenceDescriptor rds) { Object refObject = rds.getPersistentField().get(vertex.getEnvelope().getRealObject()); Class refClass = rds.getItemClass(); for (int i = 0; i < vertices.length; i++) { Edge edge = null; // ObjectEnvelope envelope = vertex.getEnvelope(); Vertex refVertex = vertices[i]; ObjectEnvelope refEnvelope = refVertex.getEnvelope(); if (refObject == refEnvelope.getRealObject()) { edge = buildConcrete11Edge(vertex, refVertex, rds.hasConstraint()); } else if (refClass.isInstance(refVertex.getEnvelope().getRealObject())) { edge = buildPotential11Edge(vertex, refVertex, rds.hasConstraint()); } if (edge != null) { if (!edgeList.contains(edge)) { edgeList.add(edge); } else { edge.increaseWeightTo(edge.getWeight()); } } } }
java
private void addObjectReferenceEdges(Vertex vertex, ObjectReferenceDescriptor rds) { Object refObject = rds.getPersistentField().get(vertex.getEnvelope().getRealObject()); Class refClass = rds.getItemClass(); for (int i = 0; i < vertices.length; i++) { Edge edge = null; // ObjectEnvelope envelope = vertex.getEnvelope(); Vertex refVertex = vertices[i]; ObjectEnvelope refEnvelope = refVertex.getEnvelope(); if (refObject == refEnvelope.getRealObject()) { edge = buildConcrete11Edge(vertex, refVertex, rds.hasConstraint()); } else if (refClass.isInstance(refVertex.getEnvelope().getRealObject())) { edge = buildPotential11Edge(vertex, refVertex, rds.hasConstraint()); } if (edge != null) { if (!edgeList.contains(edge)) { edgeList.add(edge); } else { edge.increaseWeightTo(edge.getWeight()); } } } }
[ "private", "void", "addObjectReferenceEdges", "(", "Vertex", "vertex", ",", "ObjectReferenceDescriptor", "rds", ")", "{", "Object", "refObject", "=", "rds", ".", "getPersistentField", "(", ")", ".", "get", "(", "vertex", ".", "getEnvelope", "(", ")", ".", "getRealObject", "(", ")", ")", ";", "Class", "refClass", "=", "rds", ".", "getItemClass", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "vertices", ".", "length", ";", "i", "++", ")", "{", "Edge", "edge", "=", "null", ";", "// ObjectEnvelope envelope = vertex.getEnvelope();\r", "Vertex", "refVertex", "=", "vertices", "[", "i", "]", ";", "ObjectEnvelope", "refEnvelope", "=", "refVertex", ".", "getEnvelope", "(", ")", ";", "if", "(", "refObject", "==", "refEnvelope", ".", "getRealObject", "(", ")", ")", "{", "edge", "=", "buildConcrete11Edge", "(", "vertex", ",", "refVertex", ",", "rds", ".", "hasConstraint", "(", ")", ")", ";", "}", "else", "if", "(", "refClass", ".", "isInstance", "(", "refVertex", ".", "getEnvelope", "(", ")", ".", "getRealObject", "(", ")", ")", ")", "{", "edge", "=", "buildPotential11Edge", "(", "vertex", ",", "refVertex", ",", "rds", ".", "hasConstraint", "(", ")", ")", ";", "}", "if", "(", "edge", "!=", "null", ")", "{", "if", "(", "!", "edgeList", ".", "contains", "(", "edge", ")", ")", "{", "edgeList", ".", "add", "(", "edge", ")", ";", "}", "else", "{", "edge", ".", "increaseWeightTo", "(", "edge", ".", "getWeight", "(", ")", ")", ";", "}", "}", "}", "}" ]
Finds edges based to a specific object reference descriptor and adds them to the edge map. @param vertex the object envelope vertex holding the object reference @param rds the object reference descriptor
[ "Finds", "edges", "based", "to", "a", "specific", "object", "reference", "descriptor", "and", "adds", "them", "to", "the", "edge", "map", "." ]
9a544372f67ce965f662cdc71609dd03683c8f04
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/odmg/ObjectEnvelopeOrdering.java#L284-L314
train
kuali/ojb-1.0.4
src/java/org/apache/ojb/odmg/ObjectEnvelopeOrdering.java
ObjectEnvelopeOrdering.containsObject
private static boolean containsObject(Object searchFor, Object[] searchIn) { for (int i = 0; i < searchIn.length; i++) { if (searchFor == searchIn[i]) { return true; } } return false; }
java
private static boolean containsObject(Object searchFor, Object[] searchIn) { for (int i = 0; i < searchIn.length; i++) { if (searchFor == searchIn[i]) { return true; } } return false; }
[ "private", "static", "boolean", "containsObject", "(", "Object", "searchFor", ",", "Object", "[", "]", "searchIn", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "searchIn", ".", "length", ";", "i", "++", ")", "{", "if", "(", "searchFor", "==", "searchIn", "[", "i", "]", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Helper method that searches an object array for the occurence of a specific object based on reference equality @param searchFor the object to search for @param searchIn the array to search in @return true if the object is found, otherwise false
[ "Helper", "method", "that", "searches", "an", "object", "array", "for", "the", "occurence", "of", "a", "specific", "object", "based", "on", "reference", "equality" ]
9a544372f67ce965f662cdc71609dd03683c8f04
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/odmg/ObjectEnvelopeOrdering.java#L389-L399
train
foundation-runtime/logging
logging-api/src/main/java/com/cisco/oss/foundation/logging/transactions/HttpSpringLogger.java
HttpSpringLogger.getHeadersAsMap
protected static Map<String, String> getHeadersAsMap(ResponseEntity response) { Map<String, List<String>> headers = new HashMap<>(response.getHeaders()); Map<String, String> map = new HashMap<>(); for ( Map.Entry<String, List<String>> header :headers.entrySet() ) { String headerValue = Joiner.on(",").join(header.getValue()); map.put(header.getKey(), headerValue); } return map; }
java
protected static Map<String, String> getHeadersAsMap(ResponseEntity response) { Map<String, List<String>> headers = new HashMap<>(response.getHeaders()); Map<String, String> map = new HashMap<>(); for ( Map.Entry<String, List<String>> header :headers.entrySet() ) { String headerValue = Joiner.on(",").join(header.getValue()); map.put(header.getKey(), headerValue); } return map; }
[ "protected", "static", "Map", "<", "String", ",", "String", ">", "getHeadersAsMap", "(", "ResponseEntity", "response", ")", "{", "Map", "<", "String", ",", "List", "<", "String", ">", ">", "headers", "=", "new", "HashMap", "<>", "(", "response", ".", "getHeaders", "(", ")", ")", ";", "Map", "<", "String", ",", "String", ">", "map", "=", "new", "HashMap", "<>", "(", ")", ";", "for", "(", "Map", ".", "Entry", "<", "String", ",", "List", "<", "String", ">", ">", "header", ":", "headers", ".", "entrySet", "(", ")", ")", "{", "String", "headerValue", "=", "Joiner", ".", "on", "(", "\",\"", ")", ".", "join", "(", "header", ".", "getValue", "(", ")", ")", ";", "map", ".", "put", "(", "header", ".", "getKey", "(", ")", ",", "headerValue", ")", ";", "}", "return", "map", ";", "}" ]
Flat the map of list of string to map of strings, with theoriginal values, seperated by comma
[ "Flat", "the", "map", "of", "list", "of", "string", "to", "map", "of", "strings", "with", "theoriginal", "values", "seperated", "by", "comma" ]
cd0a07b3c5b458ecf90ab92a1e0c72a067f5cbd6
https://github.com/foundation-runtime/logging/blob/cd0a07b3c5b458ecf90ab92a1e0c72a067f5cbd6/logging-api/src/main/java/com/cisco/oss/foundation/logging/transactions/HttpSpringLogger.java#L263-L274
train
kuali/ojb-1.0.4
src/java/org/apache/ojb/broker/metadata/ConnectionPoolDescriptor.java
ConnectionPoolDescriptor.init
private void init() { jdbcProperties = new Properties(); dbcpProperties = new Properties(); setFetchSize(0); this.setTestOnBorrow(true); this.setTestOnReturn(false); this.setTestWhileIdle(false); this.setLogAbandoned(false); this.setRemoveAbandoned(false); }
java
private void init() { jdbcProperties = new Properties(); dbcpProperties = new Properties(); setFetchSize(0); this.setTestOnBorrow(true); this.setTestOnReturn(false); this.setTestWhileIdle(false); this.setLogAbandoned(false); this.setRemoveAbandoned(false); }
[ "private", "void", "init", "(", ")", "{", "jdbcProperties", "=", "new", "Properties", "(", ")", ";", "dbcpProperties", "=", "new", "Properties", "(", ")", ";", "setFetchSize", "(", "0", ")", ";", "this", ".", "setTestOnBorrow", "(", "true", ")", ";", "this", ".", "setTestOnReturn", "(", "false", ")", ";", "this", ".", "setTestWhileIdle", "(", "false", ")", ";", "this", ".", "setLogAbandoned", "(", "false", ")", ";", "this", ".", "setRemoveAbandoned", "(", "false", ")", ";", "}" ]
Set some initial values.
[ "Set", "some", "initial", "values", "." ]
9a544372f67ce965f662cdc71609dd03683c8f04
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/metadata/ConnectionPoolDescriptor.java#L72-L82
train
kuali/ojb-1.0.4
src/java/org/apache/ojb/broker/metadata/ConnectionPoolDescriptor.java
ConnectionPoolDescriptor.addAttribute
public void addAttribute(String attributeName, String attributeValue) { if (attributeName != null && attributeName.startsWith(JDBC_PROPERTY_NAME_PREFIX)) { final String jdbcPropertyName = attributeName.substring(JDBC_PROPERTY_NAME_LENGTH); jdbcProperties.setProperty(jdbcPropertyName, attributeValue); } else if (attributeName != null && attributeName.startsWith(DBCP_PROPERTY_NAME_PREFIX)) { final String dbcpPropertyName = attributeName.substring(DBCP_PROPERTY_NAME_LENGTH); dbcpProperties.setProperty(dbcpPropertyName, attributeValue); } else { super.addAttribute(attributeName, attributeValue); } }
java
public void addAttribute(String attributeName, String attributeValue) { if (attributeName != null && attributeName.startsWith(JDBC_PROPERTY_NAME_PREFIX)) { final String jdbcPropertyName = attributeName.substring(JDBC_PROPERTY_NAME_LENGTH); jdbcProperties.setProperty(jdbcPropertyName, attributeValue); } else if (attributeName != null && attributeName.startsWith(DBCP_PROPERTY_NAME_PREFIX)) { final String dbcpPropertyName = attributeName.substring(DBCP_PROPERTY_NAME_LENGTH); dbcpProperties.setProperty(dbcpPropertyName, attributeValue); } else { super.addAttribute(attributeName, attributeValue); } }
[ "public", "void", "addAttribute", "(", "String", "attributeName", ",", "String", "attributeValue", ")", "{", "if", "(", "attributeName", "!=", "null", "&&", "attributeName", ".", "startsWith", "(", "JDBC_PROPERTY_NAME_PREFIX", ")", ")", "{", "final", "String", "jdbcPropertyName", "=", "attributeName", ".", "substring", "(", "JDBC_PROPERTY_NAME_LENGTH", ")", ";", "jdbcProperties", ".", "setProperty", "(", "jdbcPropertyName", ",", "attributeValue", ")", ";", "}", "else", "if", "(", "attributeName", "!=", "null", "&&", "attributeName", ".", "startsWith", "(", "DBCP_PROPERTY_NAME_PREFIX", ")", ")", "{", "final", "String", "dbcpPropertyName", "=", "attributeName", ".", "substring", "(", "DBCP_PROPERTY_NAME_LENGTH", ")", ";", "dbcpProperties", ".", "setProperty", "(", "dbcpPropertyName", ",", "attributeValue", ")", ";", "}", "else", "{", "super", ".", "addAttribute", "(", "attributeName", ",", "attributeValue", ")", ";", "}", "}" ]
Sets a custom configuration attribute. @param attributeName the attribute name. Names starting with {@link #JDBC_PROPERTY_NAME_PREFIX} will be used (without the prefix) by the ConnectionFactory when creating connections from DriverManager (not used for external DataSource connections). Names starting with {@link #DBCP_PROPERTY_NAME_PREFIX} to Commons DBCP (if used, also without prefix). @param attributeValue the attribute value
[ "Sets", "a", "custom", "configuration", "attribute", "." ]
9a544372f67ce965f662cdc71609dd03683c8f04
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/metadata/ConnectionPoolDescriptor.java#L143-L159
train
geomajas/geomajas-project-server
impl/src/main/java/org/geomajas/internal/security/DefaultSecurityContext.java
DefaultSecurityContext.userInfoInit
private void userInfoInit() { boolean first = true; userId = null; userLocale = null; userName = null; userOrganization = null; userDivision = null; if (null != authentications) { for (Authentication auth : authentications) { userId = combine(userId, auth.getUserId()); userName = combine(userName, auth.getUserName()); if (first) { userLocale = auth.getUserLocale(); first = false; } else { if (null != auth.getUserLocale() && (null == userLocale || !userLocale.equals(auth.getUserLocale()))) { userLocale = null; } } userOrganization = combine(userOrganization, auth.getUserOrganization()); userDivision = combine(userDivision, auth.getUserDivision()); } } // now calculate the "id" for this context, this should be independent of the data order, so sort Map<String, List<String>> idParts = new HashMap<String, List<String>>(); if (null != authentications) { for (Authentication auth : authentications) { List<String> auths = new ArrayList<String>(); for (BaseAuthorization ba : auth.getAuthorizations()) { auths.add(ba.getId()); } Collections.sort(auths); idParts.put(auth.getSecurityServiceId(), auths); } } StringBuilder sb = new StringBuilder(); List<String> sortedKeys = new ArrayList<String>(idParts.keySet()); Collections.sort(sortedKeys); for (String key : sortedKeys) { if (sb.length() > 0) { sb.append('|'); } List<String> auths = idParts.get(key); first = true; for (String ak : auths) { if (first) { first = false; } else { sb.append('|'); } sb.append(ak); } sb.append('@'); sb.append(key); } id = sb.toString(); }
java
private void userInfoInit() { boolean first = true; userId = null; userLocale = null; userName = null; userOrganization = null; userDivision = null; if (null != authentications) { for (Authentication auth : authentications) { userId = combine(userId, auth.getUserId()); userName = combine(userName, auth.getUserName()); if (first) { userLocale = auth.getUserLocale(); first = false; } else { if (null != auth.getUserLocale() && (null == userLocale || !userLocale.equals(auth.getUserLocale()))) { userLocale = null; } } userOrganization = combine(userOrganization, auth.getUserOrganization()); userDivision = combine(userDivision, auth.getUserDivision()); } } // now calculate the "id" for this context, this should be independent of the data order, so sort Map<String, List<String>> idParts = new HashMap<String, List<String>>(); if (null != authentications) { for (Authentication auth : authentications) { List<String> auths = new ArrayList<String>(); for (BaseAuthorization ba : auth.getAuthorizations()) { auths.add(ba.getId()); } Collections.sort(auths); idParts.put(auth.getSecurityServiceId(), auths); } } StringBuilder sb = new StringBuilder(); List<String> sortedKeys = new ArrayList<String>(idParts.keySet()); Collections.sort(sortedKeys); for (String key : sortedKeys) { if (sb.length() > 0) { sb.append('|'); } List<String> auths = idParts.get(key); first = true; for (String ak : auths) { if (first) { first = false; } else { sb.append('|'); } sb.append(ak); } sb.append('@'); sb.append(key); } id = sb.toString(); }
[ "private", "void", "userInfoInit", "(", ")", "{", "boolean", "first", "=", "true", ";", "userId", "=", "null", ";", "userLocale", "=", "null", ";", "userName", "=", "null", ";", "userOrganization", "=", "null", ";", "userDivision", "=", "null", ";", "if", "(", "null", "!=", "authentications", ")", "{", "for", "(", "Authentication", "auth", ":", "authentications", ")", "{", "userId", "=", "combine", "(", "userId", ",", "auth", ".", "getUserId", "(", ")", ")", ";", "userName", "=", "combine", "(", "userName", ",", "auth", ".", "getUserName", "(", ")", ")", ";", "if", "(", "first", ")", "{", "userLocale", "=", "auth", ".", "getUserLocale", "(", ")", ";", "first", "=", "false", ";", "}", "else", "{", "if", "(", "null", "!=", "auth", ".", "getUserLocale", "(", ")", "&&", "(", "null", "==", "userLocale", "||", "!", "userLocale", ".", "equals", "(", "auth", ".", "getUserLocale", "(", ")", ")", ")", ")", "{", "userLocale", "=", "null", ";", "}", "}", "userOrganization", "=", "combine", "(", "userOrganization", ",", "auth", ".", "getUserOrganization", "(", ")", ")", ";", "userDivision", "=", "combine", "(", "userDivision", ",", "auth", ".", "getUserDivision", "(", ")", ")", ";", "}", "}", "// now calculate the \"id\" for this context, this should be independent of the data order, so sort", "Map", "<", "String", ",", "List", "<", "String", ">", ">", "idParts", "=", "new", "HashMap", "<", "String", ",", "List", "<", "String", ">", ">", "(", ")", ";", "if", "(", "null", "!=", "authentications", ")", "{", "for", "(", "Authentication", "auth", ":", "authentications", ")", "{", "List", "<", "String", ">", "auths", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "for", "(", "BaseAuthorization", "ba", ":", "auth", ".", "getAuthorizations", "(", ")", ")", "{", "auths", ".", "add", "(", "ba", ".", "getId", "(", ")", ")", ";", "}", "Collections", ".", "sort", "(", "auths", ")", ";", "idParts", ".", "put", "(", "auth", ".", "getSecurityServiceId", "(", ")", ",", "auths", ")", ";", "}", "}", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "List", "<", "String", ">", "sortedKeys", "=", "new", "ArrayList", "<", "String", ">", "(", "idParts", ".", "keySet", "(", ")", ")", ";", "Collections", ".", "sort", "(", "sortedKeys", ")", ";", "for", "(", "String", "key", ":", "sortedKeys", ")", "{", "if", "(", "sb", ".", "length", "(", ")", ">", "0", ")", "{", "sb", ".", "append", "(", "'", "'", ")", ";", "}", "List", "<", "String", ">", "auths", "=", "idParts", ".", "get", "(", "key", ")", ";", "first", "=", "true", ";", "for", "(", "String", "ak", ":", "auths", ")", "{", "if", "(", "first", ")", "{", "first", "=", "false", ";", "}", "else", "{", "sb", ".", "append", "(", "'", "'", ")", ";", "}", "sb", ".", "append", "(", "ak", ")", ";", "}", "sb", ".", "append", "(", "'", "'", ")", ";", "sb", ".", "append", "(", "key", ")", ";", "}", "id", "=", "sb", ".", "toString", "(", ")", ";", "}" ]
Calculate UserInfo strings.
[ "Calculate", "UserInfo", "strings", "." ]
904b7d7deed1350d28955589098dd1e0a786d76e
https://github.com/geomajas/geomajas-project-server/blob/904b7d7deed1350d28955589098dd1e0a786d76e/impl/src/main/java/org/geomajas/internal/security/DefaultSecurityContext.java#L186-L244
train
geomajas/geomajas-project-server
impl/src/main/java/org/geomajas/internal/security/DefaultSecurityContext.java
DefaultSecurityContext.restoreSecurityContext
@Api public void restoreSecurityContext(SavedAuthorization savedAuthorization) { List<Authentication> auths = new ArrayList<Authentication>(); if (null != savedAuthorization) { for (SavedAuthentication sa : savedAuthorization.getAuthentications()) { Authentication auth = new Authentication(); auth.setSecurityServiceId(sa.getSecurityServiceId()); auth.setAuthorizations(sa.getAuthorizations()); auths.add(auth); } } setAuthentications(null, auths); userInfoInit(); }
java
@Api public void restoreSecurityContext(SavedAuthorization savedAuthorization) { List<Authentication> auths = new ArrayList<Authentication>(); if (null != savedAuthorization) { for (SavedAuthentication sa : savedAuthorization.getAuthentications()) { Authentication auth = new Authentication(); auth.setSecurityServiceId(sa.getSecurityServiceId()); auth.setAuthorizations(sa.getAuthorizations()); auths.add(auth); } } setAuthentications(null, auths); userInfoInit(); }
[ "@", "Api", "public", "void", "restoreSecurityContext", "(", "SavedAuthorization", "savedAuthorization", ")", "{", "List", "<", "Authentication", ">", "auths", "=", "new", "ArrayList", "<", "Authentication", ">", "(", ")", ";", "if", "(", "null", "!=", "savedAuthorization", ")", "{", "for", "(", "SavedAuthentication", "sa", ":", "savedAuthorization", ".", "getAuthentications", "(", ")", ")", "{", "Authentication", "auth", "=", "new", "Authentication", "(", ")", ";", "auth", ".", "setSecurityServiceId", "(", "sa", ".", "getSecurityServiceId", "(", ")", ")", ";", "auth", ".", "setAuthorizations", "(", "sa", ".", "getAuthorizations", "(", ")", ")", ";", "auths", ".", "add", "(", "auth", ")", ";", "}", "}", "setAuthentications", "(", "null", ",", "auths", ")", ";", "userInfoInit", "(", ")", ";", "}" ]
Restore authentications from persisted state. @param savedAuthorization saved authorizations
[ "Restore", "authentications", "from", "persisted", "state", "." ]
904b7d7deed1350d28955589098dd1e0a786d76e
https://github.com/geomajas/geomajas-project-server/blob/904b7d7deed1350d28955589098dd1e0a786d76e/impl/src/main/java/org/geomajas/internal/security/DefaultSecurityContext.java#L655-L668
train
Axway/Grapes
server/src/main/java/org/axway/grapes/server/reports/workers/DeliveryArtifactsPicker.java
DeliveryArtifactsPicker.work
public void work(RepositoryHandler repoHandler, DbProduct product) { if (!product.getDeliveries().isEmpty()) { product.getDeliveries().forEach(delivery -> { final Set<Artifact> artifacts = new HashSet<>(); final DataFetchingUtils utils = new DataFetchingUtils(); final DependencyHandler depHandler = new DependencyHandler(repoHandler); final Set<String> deliveryDependencies = utils.getDeliveryDependencies(repoHandler, depHandler, delivery); final Set<String> fullGAVCSet = deliveryDependencies.stream().filter(DataUtils::isFullGAVC).collect(Collectors.toSet()); final Set<String> shortIdentiferSet = deliveryDependencies.stream().filter(entry -> !DataUtils.isFullGAVC(entry)).collect(Collectors.toSet()); processDependencySet(repoHandler, shortIdentiferSet, batch -> String.format(BATCH_TEMPLATE_REGEX, StringUtils.join(batch, '|')), 1, artifacts::add ); processDependencySet(repoHandler, fullGAVCSet, batch -> QueryUtils.quoteIds(batch, BATCH_TEMPLATE), 10, artifacts::add ); if (!artifacts.isEmpty()) { delivery.setAllArtifactDependencies(new ArrayList<>(artifacts)); } }); repoHandler.store(product); } }
java
public void work(RepositoryHandler repoHandler, DbProduct product) { if (!product.getDeliveries().isEmpty()) { product.getDeliveries().forEach(delivery -> { final Set<Artifact> artifacts = new HashSet<>(); final DataFetchingUtils utils = new DataFetchingUtils(); final DependencyHandler depHandler = new DependencyHandler(repoHandler); final Set<String> deliveryDependencies = utils.getDeliveryDependencies(repoHandler, depHandler, delivery); final Set<String> fullGAVCSet = deliveryDependencies.stream().filter(DataUtils::isFullGAVC).collect(Collectors.toSet()); final Set<String> shortIdentiferSet = deliveryDependencies.stream().filter(entry -> !DataUtils.isFullGAVC(entry)).collect(Collectors.toSet()); processDependencySet(repoHandler, shortIdentiferSet, batch -> String.format(BATCH_TEMPLATE_REGEX, StringUtils.join(batch, '|')), 1, artifacts::add ); processDependencySet(repoHandler, fullGAVCSet, batch -> QueryUtils.quoteIds(batch, BATCH_TEMPLATE), 10, artifacts::add ); if (!artifacts.isEmpty()) { delivery.setAllArtifactDependencies(new ArrayList<>(artifacts)); } }); repoHandler.store(product); } }
[ "public", "void", "work", "(", "RepositoryHandler", "repoHandler", ",", "DbProduct", "product", ")", "{", "if", "(", "!", "product", ".", "getDeliveries", "(", ")", ".", "isEmpty", "(", ")", ")", "{", "product", ".", "getDeliveries", "(", ")", ".", "forEach", "(", "delivery", "->", "{", "final", "Set", "<", "Artifact", ">", "artifacts", "=", "new", "HashSet", "<>", "(", ")", ";", "final", "DataFetchingUtils", "utils", "=", "new", "DataFetchingUtils", "(", ")", ";", "final", "DependencyHandler", "depHandler", "=", "new", "DependencyHandler", "(", "repoHandler", ")", ";", "final", "Set", "<", "String", ">", "deliveryDependencies", "=", "utils", ".", "getDeliveryDependencies", "(", "repoHandler", ",", "depHandler", ",", "delivery", ")", ";", "final", "Set", "<", "String", ">", "fullGAVCSet", "=", "deliveryDependencies", ".", "stream", "(", ")", ".", "filter", "(", "DataUtils", "::", "isFullGAVC", ")", ".", "collect", "(", "Collectors", ".", "toSet", "(", ")", ")", ";", "final", "Set", "<", "String", ">", "shortIdentiferSet", "=", "deliveryDependencies", ".", "stream", "(", ")", ".", "filter", "(", "entry", "->", "!", "DataUtils", ".", "isFullGAVC", "(", "entry", ")", ")", ".", "collect", "(", "Collectors", ".", "toSet", "(", ")", ")", ";", "processDependencySet", "(", "repoHandler", ",", "shortIdentiferSet", ",", "batch", "->", "String", ".", "format", "(", "BATCH_TEMPLATE_REGEX", ",", "StringUtils", ".", "join", "(", "batch", ",", "'", "'", ")", ")", ",", "1", ",", "artifacts", "::", "add", ")", ";", "processDependencySet", "(", "repoHandler", ",", "fullGAVCSet", ",", "batch", "->", "QueryUtils", ".", "quoteIds", "(", "batch", ",", "BATCH_TEMPLATE", ")", ",", "10", ",", "artifacts", "::", "add", ")", ";", "if", "(", "!", "artifacts", ".", "isEmpty", "(", ")", ")", "{", "delivery", ".", "setAllArtifactDependencies", "(", "new", "ArrayList", "<>", "(", "artifacts", ")", ")", ";", "}", "}", ")", ";", "repoHandler", ".", "store", "(", "product", ")", ";", "}", "}" ]
refresh all deliveries dependencies for a particular product
[ "refresh", "all", "deliveries", "dependencies", "for", "a", "particular", "product" ]
ce9cc73d85f83eaa5fbc991abb593915a8c8374e
https://github.com/Axway/Grapes/blob/ce9cc73d85f83eaa5fbc991abb593915a8c8374e/server/src/main/java/org/axway/grapes/server/reports/workers/DeliveryArtifactsPicker.java#L36-L72
train
kuali/ojb-1.0.4
src/java/org/apache/ojb/broker/accesslayer/sql/SqlSelectStatement.java
SqlSelectStatement.getMultiJoinedClassDescriptors
private ClassDescriptor[] getMultiJoinedClassDescriptors(ClassDescriptor cld) { DescriptorRepository repository = cld.getRepository(); Class[] multiJoinedClasses = repository.getSubClassesMultipleJoinedTables(cld, true); ClassDescriptor[] result = new ClassDescriptor[multiJoinedClasses.length]; for (int i = 0 ; i < multiJoinedClasses.length; i++) { result[i] = repository.getDescriptorFor(multiJoinedClasses[i]); } return result; }
java
private ClassDescriptor[] getMultiJoinedClassDescriptors(ClassDescriptor cld) { DescriptorRepository repository = cld.getRepository(); Class[] multiJoinedClasses = repository.getSubClassesMultipleJoinedTables(cld, true); ClassDescriptor[] result = new ClassDescriptor[multiJoinedClasses.length]; for (int i = 0 ; i < multiJoinedClasses.length; i++) { result[i] = repository.getDescriptorFor(multiJoinedClasses[i]); } return result; }
[ "private", "ClassDescriptor", "[", "]", "getMultiJoinedClassDescriptors", "(", "ClassDescriptor", "cld", ")", "{", "DescriptorRepository", "repository", "=", "cld", ".", "getRepository", "(", ")", ";", "Class", "[", "]", "multiJoinedClasses", "=", "repository", ".", "getSubClassesMultipleJoinedTables", "(", "cld", ",", "true", ")", ";", "ClassDescriptor", "[", "]", "result", "=", "new", "ClassDescriptor", "[", "multiJoinedClasses", ".", "length", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "multiJoinedClasses", ".", "length", ";", "i", "++", ")", "{", "result", "[", "i", "]", "=", "repository", ".", "getDescriptorFor", "(", "multiJoinedClasses", "[", "i", "]", ")", ";", "}", "return", "result", ";", "}" ]
Get MultiJoined ClassDescriptors @param cld
[ "Get", "MultiJoined", "ClassDescriptors" ]
9a544372f67ce965f662cdc71609dd03683c8f04
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/accesslayer/sql/SqlSelectStatement.java#L128-L140
train
kuali/ojb-1.0.4
src/java/org/apache/ojb/broker/accesslayer/sql/SqlSelectStatement.java
SqlSelectStatement.appendClazzColumnForSelect
private void appendClazzColumnForSelect(StringBuffer buf) { ClassDescriptor cld = getSearchClassDescriptor(); ClassDescriptor[] clds = getMultiJoinedClassDescriptors(cld); if (clds.length == 0) { return; } buf.append(",CASE"); for (int i = clds.length; i > 0; i--) { buf.append(" WHEN "); ClassDescriptor subCld = clds[i - 1]; FieldDescriptor[] fieldDescriptors = subCld.getPkFields(); TableAlias alias = getTableAliasForClassDescriptor(subCld); for (int j = 0; j < fieldDescriptors.length; j++) { FieldDescriptor field = fieldDescriptors[j]; if (j > 0) { buf.append(" AND "); } appendColumn(alias, field, buf); buf.append(" IS NOT NULL"); } buf.append(" THEN '").append(subCld.getClassNameOfObject()).append("'"); } buf.append(" ELSE '").append(cld.getClassNameOfObject()).append("'"); buf.append(" END AS " + SqlHelper.OJB_CLASS_COLUMN); }
java
private void appendClazzColumnForSelect(StringBuffer buf) { ClassDescriptor cld = getSearchClassDescriptor(); ClassDescriptor[] clds = getMultiJoinedClassDescriptors(cld); if (clds.length == 0) { return; } buf.append(",CASE"); for (int i = clds.length; i > 0; i--) { buf.append(" WHEN "); ClassDescriptor subCld = clds[i - 1]; FieldDescriptor[] fieldDescriptors = subCld.getPkFields(); TableAlias alias = getTableAliasForClassDescriptor(subCld); for (int j = 0; j < fieldDescriptors.length; j++) { FieldDescriptor field = fieldDescriptors[j]; if (j > 0) { buf.append(" AND "); } appendColumn(alias, field, buf); buf.append(" IS NOT NULL"); } buf.append(" THEN '").append(subCld.getClassNameOfObject()).append("'"); } buf.append(" ELSE '").append(cld.getClassNameOfObject()).append("'"); buf.append(" END AS " + SqlHelper.OJB_CLASS_COLUMN); }
[ "private", "void", "appendClazzColumnForSelect", "(", "StringBuffer", "buf", ")", "{", "ClassDescriptor", "cld", "=", "getSearchClassDescriptor", "(", ")", ";", "ClassDescriptor", "[", "]", "clds", "=", "getMultiJoinedClassDescriptors", "(", "cld", ")", ";", "if", "(", "clds", ".", "length", "==", "0", ")", "{", "return", ";", "}", "buf", ".", "append", "(", "\",CASE\"", ")", ";", "for", "(", "int", "i", "=", "clds", ".", "length", ";", "i", ">", "0", ";", "i", "--", ")", "{", "buf", ".", "append", "(", "\" WHEN \"", ")", ";", "ClassDescriptor", "subCld", "=", "clds", "[", "i", "-", "1", "]", ";", "FieldDescriptor", "[", "]", "fieldDescriptors", "=", "subCld", ".", "getPkFields", "(", ")", ";", "TableAlias", "alias", "=", "getTableAliasForClassDescriptor", "(", "subCld", ")", ";", "for", "(", "int", "j", "=", "0", ";", "j", "<", "fieldDescriptors", ".", "length", ";", "j", "++", ")", "{", "FieldDescriptor", "field", "=", "fieldDescriptors", "[", "j", "]", ";", "if", "(", "j", ">", "0", ")", "{", "buf", ".", "append", "(", "\" AND \"", ")", ";", "}", "appendColumn", "(", "alias", ",", "field", ",", "buf", ")", ";", "buf", ".", "append", "(", "\" IS NOT NULL\"", ")", ";", "}", "buf", ".", "append", "(", "\" THEN '\"", ")", ".", "append", "(", "subCld", ".", "getClassNameOfObject", "(", ")", ")", ".", "append", "(", "\"'\"", ")", ";", "}", "buf", ".", "append", "(", "\" ELSE '\"", ")", ".", "append", "(", "cld", ".", "getClassNameOfObject", "(", ")", ")", ".", "append", "(", "\"'\"", ")", ";", "buf", ".", "append", "(", "\" END AS \"", "+", "SqlHelper", ".", "OJB_CLASS_COLUMN", ")", ";", "}" ]
Create the OJB_CLAZZ pseudo column based on CASE WHEN. This column defines the Class to be instantiated. @param buf
[ "Create", "the", "OJB_CLAZZ", "pseudo", "column", "based", "on", "CASE", "WHEN", ".", "This", "column", "defines", "the", "Class", "to", "be", "instantiated", "." ]
9a544372f67ce965f662cdc71609dd03683c8f04
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/accesslayer/sql/SqlSelectStatement.java#L147-L181
train
kuali/ojb-1.0.4
src/java/org/apache/ojb/odmg/NamedRootsMap.java
NamedRootsMap.lookup
Object lookup(String key) throws ObjectNameNotFoundException { Object result = null; NamedEntry entry = localLookup(key); // can't find local bound object if(entry == null) { try { PersistenceBroker broker = tx.getBroker(); // build Identity to lookup entry Identity oid = broker.serviceIdentity().buildIdentity(NamedEntry.class, key); entry = (NamedEntry) broker.getObjectByIdentity(oid); } catch(Exception e) { log.error("Can't materialize bound object for key '" + key + "'", e); } } if(entry == null) { log.info("No object found for key '" + key + "'"); } else { Object obj = entry.getObject(); // found a persistent capable object associated with that key if(obj instanceof Identity) { Identity objectIdentity = (Identity) obj; result = tx.getBroker().getObjectByIdentity(objectIdentity); // lock the persistance capable object RuntimeObject rt = new RuntimeObject(result, objectIdentity, tx, false); tx.lockAndRegister(rt, Transaction.READ, tx.getRegistrationList()); } else { // nothing else to do result = obj; } } if(result == null) throw new ObjectNameNotFoundException("Can't find named object for name '" + key + "'"); return result; }
java
Object lookup(String key) throws ObjectNameNotFoundException { Object result = null; NamedEntry entry = localLookup(key); // can't find local bound object if(entry == null) { try { PersistenceBroker broker = tx.getBroker(); // build Identity to lookup entry Identity oid = broker.serviceIdentity().buildIdentity(NamedEntry.class, key); entry = (NamedEntry) broker.getObjectByIdentity(oid); } catch(Exception e) { log.error("Can't materialize bound object for key '" + key + "'", e); } } if(entry == null) { log.info("No object found for key '" + key + "'"); } else { Object obj = entry.getObject(); // found a persistent capable object associated with that key if(obj instanceof Identity) { Identity objectIdentity = (Identity) obj; result = tx.getBroker().getObjectByIdentity(objectIdentity); // lock the persistance capable object RuntimeObject rt = new RuntimeObject(result, objectIdentity, tx, false); tx.lockAndRegister(rt, Transaction.READ, tx.getRegistrationList()); } else { // nothing else to do result = obj; } } if(result == null) throw new ObjectNameNotFoundException("Can't find named object for name '" + key + "'"); return result; }
[ "Object", "lookup", "(", "String", "key", ")", "throws", "ObjectNameNotFoundException", "{", "Object", "result", "=", "null", ";", "NamedEntry", "entry", "=", "localLookup", "(", "key", ")", ";", "// can't find local bound object\r", "if", "(", "entry", "==", "null", ")", "{", "try", "{", "PersistenceBroker", "broker", "=", "tx", ".", "getBroker", "(", ")", ";", "// build Identity to lookup entry\r", "Identity", "oid", "=", "broker", ".", "serviceIdentity", "(", ")", ".", "buildIdentity", "(", "NamedEntry", ".", "class", ",", "key", ")", ";", "entry", "=", "(", "NamedEntry", ")", "broker", ".", "getObjectByIdentity", "(", "oid", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "log", ".", "error", "(", "\"Can't materialize bound object for key '\"", "+", "key", "+", "\"'\"", ",", "e", ")", ";", "}", "}", "if", "(", "entry", "==", "null", ")", "{", "log", ".", "info", "(", "\"No object found for key '\"", "+", "key", "+", "\"'\"", ")", ";", "}", "else", "{", "Object", "obj", "=", "entry", ".", "getObject", "(", ")", ";", "// found a persistent capable object associated with that key\r", "if", "(", "obj", "instanceof", "Identity", ")", "{", "Identity", "objectIdentity", "=", "(", "Identity", ")", "obj", ";", "result", "=", "tx", ".", "getBroker", "(", ")", ".", "getObjectByIdentity", "(", "objectIdentity", ")", ";", "// lock the persistance capable object\r", "RuntimeObject", "rt", "=", "new", "RuntimeObject", "(", "result", ",", "objectIdentity", ",", "tx", ",", "false", ")", ";", "tx", ".", "lockAndRegister", "(", "rt", ",", "Transaction", ".", "READ", ",", "tx", ".", "getRegistrationList", "(", ")", ")", ";", "}", "else", "{", "// nothing else to do\r", "result", "=", "obj", ";", "}", "}", "if", "(", "result", "==", "null", ")", "throw", "new", "ObjectNameNotFoundException", "(", "\"Can't find named object for name '\"", "+", "key", "+", "\"'\"", ")", ";", "return", "result", ";", "}" ]
Return a named object associated with the specified key.
[ "Return", "a", "named", "object", "associated", "with", "the", "specified", "key", "." ]
9a544372f67ce965f662cdc71609dd03683c8f04
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/odmg/NamedRootsMap.java#L153-L196
train
kuali/ojb-1.0.4
src/java/org/apache/ojb/odmg/NamedRootsMap.java
NamedRootsMap.unbind
void unbind(String key) { NamedEntry entry = new NamedEntry(key, null, false); localUnbind(key); addForDeletion(entry); }
java
void unbind(String key) { NamedEntry entry = new NamedEntry(key, null, false); localUnbind(key); addForDeletion(entry); }
[ "void", "unbind", "(", "String", "key", ")", "{", "NamedEntry", "entry", "=", "new", "NamedEntry", "(", "key", ",", "null", ",", "false", ")", ";", "localUnbind", "(", "key", ")", ";", "addForDeletion", "(", "entry", ")", ";", "}" ]
Remove a named object
[ "Remove", "a", "named", "object" ]
9a544372f67ce965f662cdc71609dd03683c8f04
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/odmg/NamedRootsMap.java#L201-L206
train
kuali/ojb-1.0.4
src/java/org/apache/ojb/broker/metadata/MetadataManager.java
MetadataManager.readDescriptorRepository
public DescriptorRepository readDescriptorRepository(String fileName) { try { RepositoryPersistor persistor = new RepositoryPersistor(); return persistor.readDescriptorRepository(fileName); } catch (Exception e) { throw new MetadataException("Can not read repository " + fileName, e); } }
java
public DescriptorRepository readDescriptorRepository(String fileName) { try { RepositoryPersistor persistor = new RepositoryPersistor(); return persistor.readDescriptorRepository(fileName); } catch (Exception e) { throw new MetadataException("Can not read repository " + fileName, e); } }
[ "public", "DescriptorRepository", "readDescriptorRepository", "(", "String", "fileName", ")", "{", "try", "{", "RepositoryPersistor", "persistor", "=", "new", "RepositoryPersistor", "(", ")", ";", "return", "persistor", ".", "readDescriptorRepository", "(", "fileName", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "MetadataException", "(", "\"Can not read repository \"", "+", "fileName", ",", "e", ")", ";", "}", "}" ]
Read ClassDescriptors from the given repository file. @see #mergeDescriptorRepository
[ "Read", "ClassDescriptors", "from", "the", "given", "repository", "file", "." ]
9a544372f67ce965f662cdc71609dd03683c8f04
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/metadata/MetadataManager.java#L334-L345
train
kuali/ojb-1.0.4
src/java/org/apache/ojb/broker/metadata/MetadataManager.java
MetadataManager.readDescriptorRepository
public DescriptorRepository readDescriptorRepository(InputStream inst) { try { RepositoryPersistor persistor = new RepositoryPersistor(); return persistor.readDescriptorRepository(inst); } catch (Exception e) { throw new MetadataException("Can not read repository " + inst, e); } }
java
public DescriptorRepository readDescriptorRepository(InputStream inst) { try { RepositoryPersistor persistor = new RepositoryPersistor(); return persistor.readDescriptorRepository(inst); } catch (Exception e) { throw new MetadataException("Can not read repository " + inst, e); } }
[ "public", "DescriptorRepository", "readDescriptorRepository", "(", "InputStream", "inst", ")", "{", "try", "{", "RepositoryPersistor", "persistor", "=", "new", "RepositoryPersistor", "(", ")", ";", "return", "persistor", ".", "readDescriptorRepository", "(", "inst", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "MetadataException", "(", "\"Can not read repository \"", "+", "inst", ",", "e", ")", ";", "}", "}" ]
Read ClassDescriptors from the given InputStream. @see #mergeDescriptorRepository
[ "Read", "ClassDescriptors", "from", "the", "given", "InputStream", "." ]
9a544372f67ce965f662cdc71609dd03683c8f04
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/metadata/MetadataManager.java#L351-L362
train
kuali/ojb-1.0.4
src/java/org/apache/ojb/broker/metadata/MetadataManager.java
MetadataManager.readConnectionRepository
public ConnectionRepository readConnectionRepository(String fileName) { try { RepositoryPersistor persistor = new RepositoryPersistor(); return persistor.readConnectionRepository(fileName); } catch (Exception e) { throw new MetadataException("Can not read repository " + fileName, e); } }
java
public ConnectionRepository readConnectionRepository(String fileName) { try { RepositoryPersistor persistor = new RepositoryPersistor(); return persistor.readConnectionRepository(fileName); } catch (Exception e) { throw new MetadataException("Can not read repository " + fileName, e); } }
[ "public", "ConnectionRepository", "readConnectionRepository", "(", "String", "fileName", ")", "{", "try", "{", "RepositoryPersistor", "persistor", "=", "new", "RepositoryPersistor", "(", ")", ";", "return", "persistor", ".", "readConnectionRepository", "(", "fileName", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "MetadataException", "(", "\"Can not read repository \"", "+", "fileName", ",", "e", ")", ";", "}", "}" ]
Read JdbcConnectionDescriptors from the given repository file. @see #mergeConnectionRepository
[ "Read", "JdbcConnectionDescriptors", "from", "the", "given", "repository", "file", "." ]
9a544372f67ce965f662cdc71609dd03683c8f04
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/metadata/MetadataManager.java#L369-L380
train
kuali/ojb-1.0.4
src/java/org/apache/ojb/broker/metadata/MetadataManager.java
MetadataManager.readConnectionRepository
public ConnectionRepository readConnectionRepository(InputStream inst) { try { RepositoryPersistor persistor = new RepositoryPersistor(); return persistor.readConnectionRepository(inst); } catch (Exception e) { throw new MetadataException("Can not read repository from " + inst, e); } }
java
public ConnectionRepository readConnectionRepository(InputStream inst) { try { RepositoryPersistor persistor = new RepositoryPersistor(); return persistor.readConnectionRepository(inst); } catch (Exception e) { throw new MetadataException("Can not read repository from " + inst, e); } }
[ "public", "ConnectionRepository", "readConnectionRepository", "(", "InputStream", "inst", ")", "{", "try", "{", "RepositoryPersistor", "persistor", "=", "new", "RepositoryPersistor", "(", ")", ";", "return", "persistor", ".", "readConnectionRepository", "(", "inst", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "MetadataException", "(", "\"Can not read repository from \"", "+", "inst", ",", "e", ")", ";", "}", "}" ]
Read JdbcConnectionDescriptors from this InputStream. @see #mergeConnectionRepository
[ "Read", "JdbcConnectionDescriptors", "from", "this", "InputStream", "." ]
9a544372f67ce965f662cdc71609dd03683c8f04
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/metadata/MetadataManager.java#L387-L398
train
kuali/ojb-1.0.4
src/java/org/apache/ojb/broker/metadata/MetadataManager.java
MetadataManager.addProfile
public void addProfile(Object key, DescriptorRepository repository) { if (metadataProfiles.contains(key)) { throw new MetadataException("Duplicate profile key. Key '" + key + "' already exists."); } metadataProfiles.put(key, repository); }
java
public void addProfile(Object key, DescriptorRepository repository) { if (metadataProfiles.contains(key)) { throw new MetadataException("Duplicate profile key. Key '" + key + "' already exists."); } metadataProfiles.put(key, repository); }
[ "public", "void", "addProfile", "(", "Object", "key", ",", "DescriptorRepository", "repository", ")", "{", "if", "(", "metadataProfiles", ".", "contains", "(", "key", ")", ")", "{", "throw", "new", "MetadataException", "(", "\"Duplicate profile key. Key '\"", "+", "key", "+", "\"' already exists.\"", ")", ";", "}", "metadataProfiles", ".", "put", "(", "key", ",", "repository", ")", ";", "}" ]
Add a metadata profile. @see #loadProfile
[ "Add", "a", "metadata", "profile", "." ]
9a544372f67ce965f662cdc71609dd03683c8f04
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/metadata/MetadataManager.java#L488-L495
train
kuali/ojb-1.0.4
src/java/org/apache/ojb/broker/metadata/MetadataManager.java
MetadataManager.loadProfile
public void loadProfile(Object key) { if (!isEnablePerThreadChanges()) { throw new MetadataException("Can not load profile with disabled per thread mode"); } DescriptorRepository rep = (DescriptorRepository) metadataProfiles.get(key); if (rep == null) { throw new MetadataException("Can not find profile for key '" + key + "'"); } currentProfileKey.set(key); setDescriptor(rep); }
java
public void loadProfile(Object key) { if (!isEnablePerThreadChanges()) { throw new MetadataException("Can not load profile with disabled per thread mode"); } DescriptorRepository rep = (DescriptorRepository) metadataProfiles.get(key); if (rep == null) { throw new MetadataException("Can not find profile for key '" + key + "'"); } currentProfileKey.set(key); setDescriptor(rep); }
[ "public", "void", "loadProfile", "(", "Object", "key", ")", "{", "if", "(", "!", "isEnablePerThreadChanges", "(", ")", ")", "{", "throw", "new", "MetadataException", "(", "\"Can not load profile with disabled per thread mode\"", ")", ";", "}", "DescriptorRepository", "rep", "=", "(", "DescriptorRepository", ")", "metadataProfiles", ".", "get", "(", "key", ")", ";", "if", "(", "rep", "==", "null", ")", "{", "throw", "new", "MetadataException", "(", "\"Can not find profile for key '\"", "+", "key", "+", "\"'\"", ")", ";", "}", "currentProfileKey", ".", "set", "(", "key", ")", ";", "setDescriptor", "(", "rep", ")", ";", "}" ]
Load the given metadata profile for the current thread.
[ "Load", "the", "given", "metadata", "profile", "for", "the", "current", "thread", "." ]
9a544372f67ce965f662cdc71609dd03683c8f04
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/metadata/MetadataManager.java#L501-L514
train
kuali/ojb-1.0.4
src/java/org/apache/ojb/broker/metadata/MetadataManager.java
MetadataManager.buildDefaultKey
private PBKey buildDefaultKey() { List descriptors = connectionRepository().getAllDescriptor(); JdbcConnectionDescriptor descriptor; PBKey result = null; for (Iterator iterator = descriptors.iterator(); iterator.hasNext();) { descriptor = (JdbcConnectionDescriptor) iterator.next(); if (descriptor.isDefaultConnection()) { if(result != null) { log.error("Found additional connection descriptor with enabled 'default-connection' " + descriptor.getPBKey() + ". This is NOT allowed. Will use the first found descriptor " + result + " as default connection"); } else { result = descriptor.getPBKey(); } } } if(result == null) { log.info("No 'default-connection' attribute set in jdbc-connection-descriptors," + " thus it's currently not possible to use 'defaultPersistenceBroker()' " + " convenience method to lookup PersistenceBroker instances. But it's possible"+ " to enable this at runtime using 'setDefaultKey' method."); } return result; }
java
private PBKey buildDefaultKey() { List descriptors = connectionRepository().getAllDescriptor(); JdbcConnectionDescriptor descriptor; PBKey result = null; for (Iterator iterator = descriptors.iterator(); iterator.hasNext();) { descriptor = (JdbcConnectionDescriptor) iterator.next(); if (descriptor.isDefaultConnection()) { if(result != null) { log.error("Found additional connection descriptor with enabled 'default-connection' " + descriptor.getPBKey() + ". This is NOT allowed. Will use the first found descriptor " + result + " as default connection"); } else { result = descriptor.getPBKey(); } } } if(result == null) { log.info("No 'default-connection' attribute set in jdbc-connection-descriptors," + " thus it's currently not possible to use 'defaultPersistenceBroker()' " + " convenience method to lookup PersistenceBroker instances. But it's possible"+ " to enable this at runtime using 'setDefaultKey' method."); } return result; }
[ "private", "PBKey", "buildDefaultKey", "(", ")", "{", "List", "descriptors", "=", "connectionRepository", "(", ")", ".", "getAllDescriptor", "(", ")", ";", "JdbcConnectionDescriptor", "descriptor", ";", "PBKey", "result", "=", "null", ";", "for", "(", "Iterator", "iterator", "=", "descriptors", ".", "iterator", "(", ")", ";", "iterator", ".", "hasNext", "(", ")", ";", ")", "{", "descriptor", "=", "(", "JdbcConnectionDescriptor", ")", "iterator", ".", "next", "(", ")", ";", "if", "(", "descriptor", ".", "isDefaultConnection", "(", ")", ")", "{", "if", "(", "result", "!=", "null", ")", "{", "log", ".", "error", "(", "\"Found additional connection descriptor with enabled 'default-connection' \"", "+", "descriptor", ".", "getPBKey", "(", ")", "+", "\". This is NOT allowed. Will use the first found descriptor \"", "+", "result", "+", "\" as default connection\"", ")", ";", "}", "else", "{", "result", "=", "descriptor", ".", "getPBKey", "(", ")", ";", "}", "}", "}", "if", "(", "result", "==", "null", ")", "{", "log", ".", "info", "(", "\"No 'default-connection' attribute set in jdbc-connection-descriptors,\"", "+", "\" thus it's currently not possible to use 'defaultPersistenceBroker()' \"", "+", "\" convenience method to lookup PersistenceBroker instances. But it's possible\"", "+", "\" to enable this at runtime using 'setDefaultKey' method.\"", ")", ";", "}", "return", "result", ";", "}" ]
Try to build an default PBKey for convenience PB create method. @return PBKey or <code>null</code> if default key was not declared in metadata
[ "Try", "to", "build", "an", "default", "PBKey", "for", "convenience", "PB", "create", "method", "." ]
9a544372f67ce965f662cdc71609dd03683c8f04
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/metadata/MetadataManager.java#L608-L639
train
kuali/ojb-1.0.4
src/java/org/apache/ojb/broker/util/ReferenceMap.java
ReferenceMap.toReference
private Object toReference(int type, Object referent, int hash) { switch (type) { case HARD: return referent; case SOFT: return new SoftRef(hash, referent, queue); case WEAK: return new WeakRef(hash, referent, queue); default: throw new Error(); } }
java
private Object toReference(int type, Object referent, int hash) { switch (type) { case HARD: return referent; case SOFT: return new SoftRef(hash, referent, queue); case WEAK: return new WeakRef(hash, referent, queue); default: throw new Error(); } }
[ "private", "Object", "toReference", "(", "int", "type", ",", "Object", "referent", ",", "int", "hash", ")", "{", "switch", "(", "type", ")", "{", "case", "HARD", ":", "return", "referent", ";", "case", "SOFT", ":", "return", "new", "SoftRef", "(", "hash", ",", "referent", ",", "queue", ")", ";", "case", "WEAK", ":", "return", "new", "WeakRef", "(", "hash", ",", "referent", ",", "queue", ")", ";", "default", ":", "throw", "new", "Error", "(", ")", ";", "}", "}" ]
Constructs a reference of the given type to the given referent. The reference is registered with the queue for later purging. @param type HARD, SOFT or WEAK @param referent the object to refer to @param hash the hash code of the <I>key</I> of the mapping; this number might be different from referent.hashCode() if the referent represents a value and not a key
[ "Constructs", "a", "reference", "of", "the", "given", "type", "to", "the", "given", "referent", ".", "The", "reference", "is", "registered", "with", "the", "queue", "for", "later", "purging", "." ]
9a544372f67ce965f662cdc71609dd03683c8f04
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/util/ReferenceMap.java#L343-L356
train
kuali/ojb-1.0.4
src/java/org/apache/ojb/broker/util/ReferenceMap.java
ReferenceMap.getEntry
private Entry getEntry(Object key) { if (key == null) return null; int hash = hashCode(key); int index = indexFor(hash); for (Entry entry = table[index]; entry != null; entry = entry.next) { if ((entry.hash == hash) && equals(key, entry.getKey())) { return entry; } } return null; }
java
private Entry getEntry(Object key) { if (key == null) return null; int hash = hashCode(key); int index = indexFor(hash); for (Entry entry = table[index]; entry != null; entry = entry.next) { if ((entry.hash == hash) && equals(key, entry.getKey())) { return entry; } } return null; }
[ "private", "Entry", "getEntry", "(", "Object", "key", ")", "{", "if", "(", "key", "==", "null", ")", "return", "null", ";", "int", "hash", "=", "hashCode", "(", "key", ")", ";", "int", "index", "=", "indexFor", "(", "hash", ")", ";", "for", "(", "Entry", "entry", "=", "table", "[", "index", "]", ";", "entry", "!=", "null", ";", "entry", "=", "entry", ".", "next", ")", "{", "if", "(", "(", "entry", ".", "hash", "==", "hash", ")", "&&", "equals", "(", "key", ",", "entry", ".", "getKey", "(", ")", ")", ")", "{", "return", "entry", ";", "}", "}", "return", "null", ";", "}" ]
Returns the entry associated with the given key. @param key the key of the entry to look up @return the entry associated with that key, or null if the key is not in this map
[ "Returns", "the", "entry", "associated", "with", "the", "given", "key", "." ]
9a544372f67ce965f662cdc71609dd03683c8f04
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/util/ReferenceMap.java#L365-L378
train
kuali/ojb-1.0.4
src/java/org/apache/ojb/broker/util/ReferenceMap.java
ReferenceMap.indexFor
private int indexFor(int hash) { // mix the bits to avoid bucket collisions... hash += ~(hash << 15); hash ^= (hash >>> 10); hash += (hash << 3); hash ^= (hash >>> 6); hash += ~(hash << 11); hash ^= (hash >>> 16); return hash & (table.length - 1); }
java
private int indexFor(int hash) { // mix the bits to avoid bucket collisions... hash += ~(hash << 15); hash ^= (hash >>> 10); hash += (hash << 3); hash ^= (hash >>> 6); hash += ~(hash << 11); hash ^= (hash >>> 16); return hash & (table.length - 1); }
[ "private", "int", "indexFor", "(", "int", "hash", ")", "{", "// mix the bits to avoid bucket collisions...\r", "hash", "+=", "~", "(", "hash", "<<", "15", ")", ";", "hash", "^=", "(", "hash", ">>>", "10", ")", ";", "hash", "+=", "(", "hash", "<<", "3", ")", ";", "hash", "^=", "(", "hash", ">>>", "6", ")", ";", "hash", "+=", "~", "(", "hash", "<<", "11", ")", ";", "hash", "^=", "(", "hash", ">>>", "16", ")", ";", "return", "hash", "&", "(", "table", ".", "length", "-", "1", ")", ";", "}" ]
Converts the given hash code into an index into the hash table.
[ "Converts", "the", "given", "hash", "code", "into", "an", "index", "into", "the", "hash", "table", "." ]
9a544372f67ce965f662cdc71609dd03683c8f04
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/util/ReferenceMap.java#L385-L395
train
kuali/ojb-1.0.4
src/java/org/apache/ojb/broker/util/ReferenceMap.java
ReferenceMap.get
public Object get(Object key) { purge(); Entry entry = getEntry(key); if (entry == null) return null; return entry.getValue(); }
java
public Object get(Object key) { purge(); Entry entry = getEntry(key); if (entry == null) return null; return entry.getValue(); }
[ "public", "Object", "get", "(", "Object", "key", ")", "{", "purge", "(", ")", ";", "Entry", "entry", "=", "getEntry", "(", "key", ")", ";", "if", "(", "entry", "==", "null", ")", "return", "null", ";", "return", "entry", ".", "getValue", "(", ")", ";", "}" ]
Returns the value associated with the given key, if any. @return the value associated with the given key, or <Code>null</Code> if the key maps to no value
[ "Returns", "the", "value", "associated", "with", "the", "given", "key", "if", "any", "." ]
9a544372f67ce965f662cdc71609dd03683c8f04
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/util/ReferenceMap.java#L521-L527
train
kuali/ojb-1.0.4
src/java/org/apache/ojb/broker/util/ReferenceMap.java
ReferenceMap.remove
public Object remove(Object key) { if (key == null) return null; purge(); int hash = hashCode(key); int index = indexFor(hash); Entry previous = null; Entry entry = table[index]; while (entry != null) { if ((hash == entry.hash) && equals(key, entry.getKey())) { if (previous == null) table[index] = entry.next; else previous.next = entry.next; this.size--; modCount++; return entry.getValue(); } previous = entry; entry = entry.next; } return null; }
java
public Object remove(Object key) { if (key == null) return null; purge(); int hash = hashCode(key); int index = indexFor(hash); Entry previous = null; Entry entry = table[index]; while (entry != null) { if ((hash == entry.hash) && equals(key, entry.getKey())) { if (previous == null) table[index] = entry.next; else previous.next = entry.next; this.size--; modCount++; return entry.getValue(); } previous = entry; entry = entry.next; } return null; }
[ "public", "Object", "remove", "(", "Object", "key", ")", "{", "if", "(", "key", "==", "null", ")", "return", "null", ";", "purge", "(", ")", ";", "int", "hash", "=", "hashCode", "(", "key", ")", ";", "int", "index", "=", "indexFor", "(", "hash", ")", ";", "Entry", "previous", "=", "null", ";", "Entry", "entry", "=", "table", "[", "index", "]", ";", "while", "(", "entry", "!=", "null", ")", "{", "if", "(", "(", "hash", "==", "entry", ".", "hash", ")", "&&", "equals", "(", "key", ",", "entry", ".", "getKey", "(", ")", ")", ")", "{", "if", "(", "previous", "==", "null", ")", "table", "[", "index", "]", "=", "entry", ".", "next", ";", "else", "previous", ".", "next", "=", "entry", ".", "next", ";", "this", ".", "size", "--", ";", "modCount", "++", ";", "return", "entry", ".", "getValue", "(", ")", ";", "}", "previous", "=", "entry", ";", "entry", "=", "entry", ".", "next", ";", "}", "return", "null", ";", "}" ]
Removes the key and its associated value from this map. @param key the key to remove @return the value associated with that key, or null if the key was not in the map
[ "Removes", "the", "key", "and", "its", "associated", "value", "from", "this", "map", "." ]
9a544372f67ce965f662cdc71609dd03683c8f04
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/util/ReferenceMap.java#L578-L602
train