code
stringlengths 67
466k
| docstring
stringlengths 1
13.2k
|
---|---|
public final boolean roll(final LoggingEvent loggingEvent) {
boolean rolled = false;
this.takeTimeSample(loggingEvent);
final long nextRolloverTime = this.getNextRolloverTimeMillis();
if (this.isRolloverDue(nextRolloverTime)) {
super.roll(this.sampledTime());
this.updateNextRolloverTime();
rolled = true;
}
this.storeTimeSample();
return rolled;
} | Not thread-safe.
@see FileRollable#roll(org.apache.log4j.spi.LoggingEvent) |
@PostConstruct
protected void checkPluginDependencies() throws GeomajasException {
if ("true".equals(System.getProperty("skipPluginDependencyCheck"))) {
return;
}
if (null == declaredPlugins) {
return;
}
// start by going through all plug-ins to build a map of versions for plug-in keys
// includes verification that each key is only used once
Map<String, String> versions = new HashMap<String, String>();
for (PluginInfo plugin : declaredPlugins.values()) {
String name = plugin.getVersion().getName();
String version = plugin.getVersion().getVersion();
// check for multiple plugin with same name but different versions (duplicates allowed for jar+source dep)
if (null != version) {
String otherVersion = versions.get(name);
if (null != otherVersion) {
if (!version.startsWith(EXPR_START)) {
if (!otherVersion.startsWith(EXPR_START) && !otherVersion.equals(version)) {
throw new GeomajasException(ExceptionCode.DEPENDENCY_CHECK_INVALID_DUPLICATE,
name, version, versions.get(name));
}
versions.put(name, version);
}
} else {
versions.put(name, version);
}
}
}
// Check dependencies
StringBuilder message = new StringBuilder();
String backendVersion = versions.get("Geomajas");
for (PluginInfo plugin : declaredPlugins.values()) {
String name = plugin.getVersion().getName();
message.append(checkVersion(name, "Geomajas back-end", plugin.getBackendVersion(), backendVersion));
List<PluginVersionInfo> dependencies = plugin.getDependencies();
if (null != dependencies) {
for (PluginVersionInfo dependency : plugin.getDependencies()) {
String depName = dependency.getName();
message.append(checkVersion(name, depName, dependency.getVersion(), versions.get(depName)));
}
}
dependencies = plugin.getOptionalDependencies();
if (null != dependencies) {
for (PluginVersionInfo dependency : dependencies) {
String depName = dependency.getName();
String availableVersion = versions.get(depName);
if (null != availableVersion) {
message.append(checkVersion(name, depName, dependency.getVersion(), versions.get(depName)));
}
}
}
}
if (message.length() > 0) {
throw new GeomajasException(ExceptionCode.DEPENDENCY_CHECK_FAILED, message.toString());
}
recorder.record(GROUP, VALUE);
} | Finish initializing.
@throws GeomajasException oops |
String checkVersion(String pluginName, String dependency, String requestedVersion, String availableVersion) {
if (null == availableVersion) {
return "Dependency " + dependency + " not found for " + pluginName + ", version " + requestedVersion +
" or higher needed.\n";
}
if (requestedVersion.startsWith(EXPR_START) || availableVersion.startsWith(EXPR_START)) {
return "";
}
Version requested = new Version(requestedVersion);
Version available = new Version(availableVersion);
if (requested.getMajor() != available.getMajor()) {
return "Dependency " + dependency + " is provided in a incompatible API version for plug-in " +
pluginName + ", which requests version " + requestedVersion +
", but version " + availableVersion + " supplied.\n";
}
if (requested.after(available)) {
return "Dependency " + dependency + " too old for " + pluginName + ", version " + requestedVersion +
" or higher needed, but version " + availableVersion + " supplied.\n";
}
return "";
} | Check the version to assure it is allowed.
@param pluginName plugin name which needs the dependency
@param dependency dependency which needs to be verified
@param requestedVersion requested/minimum version
@param availableVersion available version
@return version check problem or empty string when all is fine |
static FieldType newFieldType(JdbcType jdbcType)
{
FieldType result = null;
switch (jdbcType.getType())
{
case Types.ARRAY:
result = new ArrayFieldType();
break;
case Types.BIGINT:
result = new LongFieldType();
break;
case Types.BINARY:
result = new ByteArrayFieldType();
break;
case Types.BIT:
result = new BooleanFieldType();
break;
case Types.BLOB:
result = new BlobFieldType();
break;
case Types.CHAR:
result = new StringFieldType();
break;
case Types.CLOB:
result = new ClobFieldType();
break;
case Types.DATE:
result = new DateFieldType();
break;
case Types.DECIMAL:
result = new BigDecimalFieldType();
break;
// Not needed, user have to use the underlying sql datatype in OJB mapping files
// case Types.DISTINCT:
// result = new DistinctFieldType();
// break;
case Types.DOUBLE:
result = new DoubleFieldType();
break;
case Types.FLOAT:
result = new FloatFieldType();
break;
case Types.INTEGER:
result = new IntegerFieldType();
break;
case Types.JAVA_OBJECT:
result = new JavaObjectFieldType();
break;
case Types.LONGVARBINARY:
result = new ByteArrayFieldType();
break;
case Types.LONGVARCHAR:
result = new StringFieldType();
break;
case Types.NUMERIC:
result = new BigDecimalFieldType();
break;
case Types.REAL:
result = new FloatFieldType();
break;
case Types.REF:
result = new RefFieldType();
break;
case Types.SMALLINT:
result = new ShortFieldType();
break;
case Types.STRUCT:
result = new StructFieldType();
break;
case Types.TIME:
result = new TimeFieldType();
break;
case Types.TIMESTAMP:
result = new TimestampFieldType();
break;
case Types.TINYINT:
result = new ByteFieldType();
break;
case Types.VARBINARY:
result = new ByteArrayFieldType();
break;
case Types.VARCHAR:
result = new StringFieldType();
break;
case Types.OTHER:
result = new JavaObjectFieldType();
break;
//
// case Types.NULL:
// result = new NullFieldType();
// break;
//#ifdef JDBC30
case Types.BOOLEAN:
result = new BooleanFieldType();
break;
case Types.DATALINK:
result = new URLFieldType();
break;
//#endif
default:
throw new OJBRuntimeException("Unkown or not supported field type specified, specified jdbc type was '"
+ jdbcType + "', as string: " + JdbcTypesHelper.getSqlTypeAsString(jdbcType.getType()));
}
// make sure that the sql type was set
result.setSqlType(jdbcType);
return result;
} | Returns a {@link FieldType} instance for the given sql type
(see {@link java.sql.Types}) as specified in JDBC 3.0 specification
(see JDBC 3.0 specification <em>Appendix B, Data Type Conversion Tables</em>).
@param jdbcType Specify the type to look for.
@return A new specific {@link FieldType} instance. |
public void check(ClassDescriptorDef classDef, String checkLevel) throws ConstraintException
{
ensureNoTableInfoIfNoRepositoryInfo(classDef, checkLevel);
checkModifications(classDef, checkLevel);
checkExtents(classDef, checkLevel);
ensureTableIfNecessary(classDef, checkLevel);
checkFactoryClassAndMethod(classDef, checkLevel);
checkInitializationMethod(classDef, checkLevel);
checkPrimaryKey(classDef, checkLevel);
checkProxyPrefetchingLimit(classDef, checkLevel);
checkRowReader(classDef, checkLevel);
checkObjectCache(classDef, checkLevel);
checkProcedures(classDef, checkLevel);
} | Checks the given class descriptor.
@param classDef The class descriptor
@param checkLevel The amount of checks to perform
@exception ConstraintException If a constraint has been violated |
private void ensureNoTableInfoIfNoRepositoryInfo(ClassDescriptorDef classDef, String checkLevel)
{
if (!classDef.getBooleanProperty(PropertyHelper.OJB_PROPERTY_GENERATE_REPOSITORY_INFO, true))
{
classDef.setProperty(PropertyHelper.OJB_PROPERTY_GENERATE_TABLE_INFO, "false");
}
} | Ensures that generate-table-info is set to false if generate-repository-info is set to false.
@param classDef The class descriptor
@param checkLevel The current check level (this constraint is checked in all levels) |
private void checkModifications(ClassDescriptorDef classDef, String checkLevel) throws ConstraintException
{
if (CHECKLEVEL_NONE.equals(checkLevel))
{
return;
}
HashMap features = new HashMap();
FeatureDescriptorDef def;
for (Iterator it = classDef.getFields(); it.hasNext();)
{
def = (FeatureDescriptorDef)it.next();
features.put(def.getName(), def);
}
for (Iterator it = classDef.getReferences(); it.hasNext();)
{
def = (FeatureDescriptorDef)it.next();
features.put(def.getName(), def);
}
for (Iterator it = classDef.getCollections(); it.hasNext();)
{
def = (FeatureDescriptorDef)it.next();
features.put(def.getName(), def);
}
// now checking the modifications
Properties mods;
String modName;
String propName;
for (Iterator it = classDef.getModificationNames(); it.hasNext();)
{
modName = (String)it.next();
if (!features.containsKey(modName))
{
throw new ConstraintException("Class "+classDef.getName()+" contains a modification for an unknown feature "+modName);
}
def = (FeatureDescriptorDef)features.get(modName);
if (def.getOriginal() == null)
{
throw new ConstraintException("Class "+classDef.getName()+" contains a modification for a feature "+modName+" that is not inherited but defined in the same class");
}
// checking modification
mods = classDef.getModification(modName);
for (Iterator propIt = mods.keySet().iterator(); propIt.hasNext();)
{
propName = (String)propIt.next();
if (!PropertyHelper.isPropertyAllowed(def.getClass(), propName))
{
throw new ConstraintException("The modification of attribute "+propName+" in class "+classDef.getName()+" is not applicable to the feature "+modName);
}
}
}
} | Checks that the modified features exist.
@param classDef The class descriptor
@param checkLevel The current check level (this constraint is checked in basic and strict)
@exception ConstraintException If the constraint has been violated |
private void checkExtents(ClassDescriptorDef classDef, String checkLevel) throws ConstraintException
{
if (CHECKLEVEL_NONE.equals(checkLevel))
{
return;
}
HashMap processedClasses = new HashMap();
InheritanceHelper helper = new InheritanceHelper();
ClassDescriptorDef curExtent;
boolean canBeRemoved;
for (Iterator it = classDef.getExtentClasses(); it.hasNext();)
{
curExtent = (ClassDescriptorDef)it.next();
canBeRemoved = false;
if (classDef.getName().equals(curExtent.getName()))
{
throw new ConstraintException("The class "+classDef.getName()+" specifies itself as an extent-class");
}
else if (processedClasses.containsKey(curExtent))
{
canBeRemoved = true;
}
else
{
try
{
if (!helper.isSameOrSubTypeOf(curExtent, classDef.getName(), false))
{
throw new ConstraintException("The class "+classDef.getName()+" specifies an extent-class "+curExtent.getName()+" that is not a sub-type of it");
}
// now we check whether we already have an extent for a base-class of this extent-class
for (Iterator processedIt = processedClasses.keySet().iterator(); processedIt.hasNext();)
{
if (helper.isSameOrSubTypeOf(curExtent, ((ClassDescriptorDef)processedIt.next()).getName(), false))
{
canBeRemoved = true;
break;
}
}
}
catch (ClassNotFoundException ex)
{
// won't happen because we don't use lookup of the actual classes
}
}
if (canBeRemoved)
{
it.remove();
}
processedClasses.put(curExtent, null);
}
} | Checks the extents specifications and removes unnecessary entries.
@param classDef The class descriptor
@param checkLevel The current check level (this constraint is checked in basic and strict)
@exception ConstraintException If the constraint has been violated |
private void ensureTableIfNecessary(ClassDescriptorDef classDef, String checkLevel)
{
if (classDef.getBooleanProperty(PropertyHelper.OJB_PROPERTY_OJB_PERSISTENT, false))
{
if (!classDef.hasProperty(PropertyHelper.OJB_PROPERTY_TABLE))
{
classDef.setProperty(PropertyHelper.OJB_PROPERTY_TABLE, classDef.getDefaultTableName());
}
}
} | Makes sure that the class descriptor has a table attribute if it requires it (i.e. it is
relevant for the repository descriptor).
@param classDef The class descriptor
@param checkLevel The current check level (this constraint is checked in all levels) |
private void checkFactoryClassAndMethod(ClassDescriptorDef classDef, String checkLevel) throws ConstraintException
{
if (CHECKLEVEL_NONE.equals(checkLevel))
{
return;
}
String factoryClassName = classDef.getProperty(PropertyHelper.OJB_PROPERTY_FACTORY_CLASS);
String factoryMethodName = classDef.getProperty(PropertyHelper.OJB_PROPERTY_FACTORY_METHOD);
if ((factoryClassName == null) && (factoryMethodName == null))
{
return;
}
if ((factoryClassName != null) && (factoryMethodName == null))
{
throw new ConstraintException("Class "+classDef.getName()+" has a factory-class but no factory-method.");
}
if ((factoryClassName == null) && (factoryMethodName != null))
{
throw new ConstraintException("Class "+classDef.getName()+" has a factory-method but no factory-class.");
}
if (CHECKLEVEL_STRICT.equals(checkLevel))
{
Class factoryClass;
Method factoryMethod;
try
{
factoryClass = InheritanceHelper.getClass(factoryClassName);
}
catch (ClassNotFoundException ex)
{
throw new ConstraintException("The class "+factoryClassName+" specified as factory-class of class "+classDef.getName()+" was not found on the classpath");
}
try
{
factoryMethod = factoryClass.getDeclaredMethod(factoryMethodName, new Class[0]);
}
catch (NoSuchMethodException ex)
{
factoryMethod = null;
}
catch (Exception ex)
{
throw new ConstraintException("Exception while checking the factory-class "+factoryClassName+" of class "+classDef.getName()+": "+ex.getMessage());
}
if (factoryMethod == null)
{
try
{
factoryMethod = factoryClass.getMethod(factoryMethodName, new Class[0]);
}
catch (NoSuchMethodException ex)
{
throw new ConstraintException("No suitable factory-method "+factoryMethodName+" found in the factory-class "+factoryClassName+" of class "+classDef.getName());
}
catch (Exception ex)
{
throw new ConstraintException("Exception while checking the factory-class "+factoryClassName+" of class "+classDef.getName()+": "+ex.getMessage());
}
}
// checking return type and modifiers
Class returnType = factoryMethod.getReturnType();
InheritanceHelper helper = new InheritanceHelper();
if ("void".equals(returnType.getName()))
{
throw new ConstraintException("The factory-method "+factoryMethodName+" in factory-class "+factoryClassName+" of class "+classDef.getName()+" must return a value");
}
try
{
if (!helper.isSameOrSubTypeOf(returnType.getName(), classDef.getName()))
{
throw new ConstraintException("The method "+factoryMethodName+" in factory-class "+factoryClassName+" of class "+classDef.getName()+" must return the type "+classDef.getName()+" or a subtype of it");
}
}
catch (ClassNotFoundException ex)
{
throw new ConstraintException("Could not find the class "+ex.getMessage()+" on the classpath while checking the factory-method "+factoryMethodName+" in the factory-class "+factoryClassName+" of class "+classDef.getName());
}
if (!Modifier.isStatic(factoryMethod.getModifiers()))
{
throw new ConstraintException("The factory-method "+factoryMethodName+" in factory-class "+factoryClassName+" of class "+classDef.getName()+" must be static");
}
}
} | Checks the given class descriptor for correct factory-class and factory-method.
@param classDef The class descriptor
@param checkLevel The current check level (this constraint is checked in basic (partly) and strict)
@exception ConstraintException If the constraint has been violated |
private void checkInitializationMethod(ClassDescriptorDef classDef, String checkLevel) throws ConstraintException
{
if (!CHECKLEVEL_STRICT.equals(checkLevel))
{
return;
}
String initMethodName = classDef.getProperty(PropertyHelper.OJB_PROPERTY_INITIALIZATION_METHOD);
if (initMethodName == null)
{
return;
}
Class initClass;
Method initMethod;
try
{
initClass = InheritanceHelper.getClass(classDef.getName());
}
catch (ClassNotFoundException ex)
{
throw new ConstraintException("The class "+classDef.getName()+" was not found on the classpath");
}
try
{
initMethod = initClass.getDeclaredMethod(initMethodName, new Class[0]);
}
catch (NoSuchMethodException ex)
{
initMethod = null;
}
catch (Exception ex)
{
throw new ConstraintException("Exception while checking the class "+classDef.getName()+": "+ex.getMessage());
}
if (initMethod == null)
{
try
{
initMethod = initClass.getMethod(initMethodName, new Class[0]);
}
catch (NoSuchMethodException ex)
{
throw new ConstraintException("No suitable initialization-method "+initMethodName+" found in class "+classDef.getName());
}
catch (Exception ex)
{
throw new ConstraintException("Exception while checking the class "+classDef.getName()+": "+ex.getMessage());
}
}
// checking modifiers
int mods = initMethod.getModifiers();
if (Modifier.isStatic(mods) || Modifier.isAbstract(mods))
{
throw new ConstraintException("The initialization-method "+initMethodName+" in class "+classDef.getName()+" must be a concrete instance method");
}
} | Checks the initialization-method of given class descriptor.
@param classDef The class descriptor
@param checkLevel The current check level (this constraint is only checked in strict)
@exception ConstraintException If the constraint has been violated |
private void checkPrimaryKey(ClassDescriptorDef classDef, String checkLevel) throws ConstraintException
{
if (CHECKLEVEL_NONE.equals(checkLevel))
{
return;
}
if (classDef.getBooleanProperty(PropertyHelper.OJB_PROPERTY_GENERATE_TABLE_INFO, true) &&
classDef.getPrimaryKeys().isEmpty())
{
LogHelper.warn(true,
getClass(),
"checkPrimaryKey",
"The class "+classDef.getName()+" has no primary key");
}
} | Checks whether given class descriptor has a primary key.
@param classDef The class descriptor
@param checkLevel The current check level (this constraint is only checked in strict)
@exception ConstraintException If the constraint has been violated |
private void checkRowReader(ClassDescriptorDef classDef, String checkLevel) throws ConstraintException
{
if (!CHECKLEVEL_STRICT.equals(checkLevel))
{
return;
}
String rowReaderName = classDef.getProperty(PropertyHelper.OJB_PROPERTY_ROW_READER);
if (rowReaderName == null)
{
return;
}
try
{
InheritanceHelper helper = new InheritanceHelper();
if (!helper.isSameOrSubTypeOf(rowReaderName, ROW_READER_INTERFACE))
{
throw new ConstraintException("The class "+rowReaderName+" specified as row-reader of class "+classDef.getName()+" does not implement the interface "+ROW_READER_INTERFACE);
}
}
catch (ClassNotFoundException ex)
{
throw new ConstraintException("Could not find the class "+ex.getMessage()+" on the classpath while checking the row-reader class "+rowReaderName+" of class "+classDef.getName());
}
} | Checks the given class descriptor for correct row-reader setting.
@param classDef The class descriptor
@param checkLevel The current check level (this constraint is only checked in strict)
@exception ConstraintException If the constraint has been violated |
private void checkObjectCache(ClassDescriptorDef classDef, String checkLevel) throws ConstraintException
{
if (!CHECKLEVEL_STRICT.equals(checkLevel))
{
return;
}
ObjectCacheDef objCacheDef = classDef.getObjectCache();
if (objCacheDef == null)
{
return;
}
String objectCacheName = objCacheDef.getName();
if ((objectCacheName == null) || (objectCacheName.length() == 0))
{
throw new ConstraintException("No class specified for the object-cache of class "+classDef.getName());
}
try
{
InheritanceHelper helper = new InheritanceHelper();
if (!helper.isSameOrSubTypeOf(objectCacheName, OBJECT_CACHE_INTERFACE))
{
throw new ConstraintException("The class "+objectCacheName+" specified as object-cache of class "+classDef.getName()+" does not implement the interface "+OBJECT_CACHE_INTERFACE);
}
}
catch (ClassNotFoundException ex)
{
throw new ConstraintException("Could not find the class "+ex.getMessage()+" on the classpath while checking the object-cache class "+objectCacheName+" of class "+classDef.getName());
}
} | Checks the given class descriptor for correct object cache setting.
@param classDef The class descriptor
@param checkLevel The current check level (this constraint is only checked in strict)
@exception ConstraintException If the constraint has been violated |
private void checkProcedures(ClassDescriptorDef classDef, String checkLevel) throws ConstraintException
{
if (CHECKLEVEL_NONE.equals(checkLevel))
{
return;
}
ProcedureDef procDef;
String type;
String name;
String fieldName;
String argName;
for (Iterator it = classDef.getProcedures(); it.hasNext();)
{
procDef = (ProcedureDef)it.next();
type = procDef.getName();
name = procDef.getProperty(PropertyHelper.OJB_PROPERTY_NAME);
if ((name == null) || (name.length() == 0))
{
throw new ConstraintException("The "+type+"-procedure in class "+classDef.getName()+" doesn't have a name");
}
fieldName = procDef.getProperty(PropertyHelper.OJB_PROPERTY_RETURN_FIELD_REF);
if ((fieldName != null) && (fieldName.length() > 0))
{
if (classDef.getField(fieldName) == null)
{
throw new ConstraintException("The "+type+"-procedure "+name+" in class "+classDef.getName()+" references an unknown or non-persistent return field "+fieldName);
}
}
for (CommaListIterator argIt = new CommaListIterator(procDef.getProperty(PropertyHelper.OJB_PROPERTY_ARGUMENTS)); argIt.hasNext();)
{
argName = argIt.getNext();
if (classDef.getProcedureArgument(argName) == null)
{
throw new ConstraintException("The "+type+"-procedure "+name+" in class "+classDef.getName()+" references an unknown argument "+argName);
}
}
}
ProcedureArgumentDef argDef;
for (Iterator it = classDef.getProcedureArguments(); it.hasNext();)
{
argDef = (ProcedureArgumentDef)it.next();
type = argDef.getProperty(PropertyHelper.OJB_PROPERTY_TYPE);
if ("runtime".equals(type))
{
fieldName = argDef.getProperty(PropertyHelper.OJB_PROPERTY_FIELD_REF);
if ((fieldName != null) && (fieldName.length() > 0))
{
if (classDef.getField(fieldName) == null)
{
throw new ConstraintException("The "+type+"-argument "+argDef.getName()+" in class "+classDef.getName()+" references an unknown or non-persistent return field "+fieldName);
}
}
}
}
} | Checks the given class descriptor for correct procedure settings.
@param classDef The class descriptor
@param checkLevel The current check level (this constraint is checked in basic and strict)
@exception ConstraintException If the constraint has been violated |
OTMConnection getConnection()
{
if (m_connection == null)
{
OTMConnectionRuntimeException ex = new OTMConnectionRuntimeException("Connection is null.");
sendEvents(ConnectionEvent.CONNECTION_ERROR_OCCURRED, ex, null);
}
return m_connection;
} | get the underlying wrapped connection
@return OTMConnection raw connection to the OTM. |
void sendEvents(int eventType, Exception ex, Object connectionHandle)
{
ConnectionEvent ce = null;
if (ex == null)
{
ce = new ConnectionEvent(this, eventType);
}
else
{
ce = new ConnectionEvent(this, eventType, ex);
}
ce.setConnectionHandle(connectionHandle);
Collection copy = null;
synchronized (m_connectionEventListeners)
{
copy = new ArrayList(m_connectionEventListeners);
}
switch (ce.getId())
{
case ConnectionEvent.CONNECTION_CLOSED:
for (Iterator i = copy.iterator(); i.hasNext();)
{
ConnectionEventListener cel = (ConnectionEventListener) i.next();
cel.connectionClosed(ce);
}
break;
case ConnectionEvent.LOCAL_TRANSACTION_STARTED:
for (Iterator i = copy.iterator(); i.hasNext();)
{
ConnectionEventListener cel = (ConnectionEventListener) i.next();
cel.localTransactionStarted(ce);
}
break;
case ConnectionEvent.LOCAL_TRANSACTION_COMMITTED:
for (Iterator i = copy.iterator(); i.hasNext();)
{
ConnectionEventListener cel = (ConnectionEventListener) i.next();
cel.localTransactionCommitted(ce);
}
break;
case ConnectionEvent.LOCAL_TRANSACTION_ROLLEDBACK:
for (Iterator i = copy.iterator(); i.hasNext();)
{
ConnectionEventListener cel = (ConnectionEventListener) i.next();
cel.localTransactionRolledback(ce);
}
break;
case ConnectionEvent.CONNECTION_ERROR_OCCURRED:
for (Iterator i = copy.iterator(); i.hasNext();)
{
ConnectionEventListener cel = (ConnectionEventListener) i.next();
cel.connectionErrorOccurred(ce);
}
break;
default:
throw new IllegalArgumentException("Illegal eventType: " + ce.getId());
}
} | Section 6.5.6 of the JCA 1.5 spec instructs ManagedConnection instances to notify connection listeners with
close/error and local transaction-related events to its registered set of listeners.
The events for begin/commit/rollback are only sent if the application server did NOT
initiate the actions.
This method dispatchs all events to the listeners based on the eventType
@param eventType as enumerated in the ConnectionEvents interface
@param ex an optional exception if we are sending an error message
@param connectionHandle an optional connectionHandle if we have access to it. |
private Integer getReleaseId() {
final String[] versionParts = stringVersion.split("-");
if(isBranch() && versionParts.length >= 3){
return Integer.valueOf(versionParts[2]);
}
else if(versionParts.length >= 2){
return Integer.valueOf(versionParts[1]);
}
return 0;
} | Return the releaseId
@return releaseId |
public int compare(final Version other) throws IncomparableException{
// Cannot compare branch versions and others
if(!isBranch().equals(other.isBranch())){
throw new IncomparableException();
}
// Compare digits
final int minDigitSize = getDigitsSize() < other.getDigitsSize()? getDigitsSize(): other.getDigitsSize();
for(int i = 0; i < minDigitSize ; i++){
if(!getDigit(i).equals(other.getDigit(i))){
return getDigit(i).compareTo(other.getDigit(i));
}
}
// If not the same number of digits and the first digits are equals, the longest is the newer
if(!getDigitsSize().equals(other.getDigitsSize())){
return getDigitsSize() > other.getDigitsSize()? 1: -1;
}
if(isBranch() && !getBranchId().equals(other.getBranchId())){
return getBranchId().compareTo(other.getBranchId());
}
// if the digits are the same, a snapshot is newer than a release
if(isSnapshot() && other.isRelease()){
return 1;
}
if(isRelease() && other.isSnapshot()){
return -1;
}
// if both versions are releases, compare the releaseID
if(isRelease() && other.isRelease()){
return getReleaseId().compareTo(other.getReleaseId());
}
return 0;
} | Compare two versions
@param other
@return an integer: 0 if equals, -1 if older, 1 if newer
@throws IncomparableException is thrown when two versions are not coparable |
public boolean upgradeLock(TransactionImpl tx, Object obj)
{
LockEntry writer = getWriter(obj);
if (writer == null)
{
Collection readers = this.getReaders(obj);
if (readers.size() == 1)
{
LockEntry reader = (LockEntry) readers.iterator().next();
if (reader.isOwnedBy(tx))
{
if (upgradeLock(reader))
return true;
else
return upgradeLock(tx, obj);
}
}
else if (readers.size() == 0)
{
if (setWriter(tx, obj))
return true;
else
return upgradeLock(tx, obj);
}
}
else if (writer.isOwnedBy(tx))
{
return true; // If I already have Write, then I've upgraded.
}
return false;
} | acquire a lock upgrade (from read to write) lock on Object obj for Transaction tx.
@param tx the transaction requesting the lock
@param obj the Object to be locked
@return true if successful, else false |
public boolean releaseLock(TransactionImpl tx, Object obj)
{
LockEntry writer = getWriter(obj);
if (writer != null && writer.isOwnedBy(tx))
{
removeWriter(writer);
return true;
}
if (hasReadLock(tx, obj))
{
removeReader(tx, obj);
return true;
}
return false;
} | release a lock on Object obj for Transaction tx.
@param tx the transaction releasing the lock
@param obj the Object to be unlocked
@return true if successful, else false |
public String getOpeningTagById(int elementId, String attributes)
{
return "<" + table.getKeyByValue(new Integer(elementId)) + " " + attributes + ">";
} | returns the opening xml-tag associated with the repository element with
id <code>elementId</code>.
@return the resulting tag |
public String getAttribute(int elementId, String value)
{
return table.getKeyByValue(new Integer(elementId)) + "=\"" + value + "\"";
} | returns the opening but non-closing xml-tag
associated with the repository element with
id <code>elementId</code>.
@return the resulting tag |
public int getIdByTag(String tag)
{
Integer value = (Integer) table.getValueByKey(tag);
if (value == null)
LoggerFactory.getDefaultLogger().error(
"** " + this.getClass().getName() + ": Tag '" + tag + "' is not defined. **");
return value.intValue();
} | returns the repository element id associated with the xml-tag
literal <code>tag</code>.
@return the resulting repository element id.
@throws NullPointerException if no value was found for <b>tag</b> |
public String getCompleteTagById(int elementId, String characters)
{
String result = getOpeningTagById(elementId);
result += characters;
result += getClosingTagById(elementId);
return result;
} | returns the opening xml-tag associated with the repository element with
id <code>elementId</code>.
@return the resulting tag |
public void calculateSize(PdfContext context) {
float width = 0;
float height = 0;
for (PrintComponent<?> child : children) {
child.calculateSize(context);
float cw = child.getBounds().getWidth() + 2 * child.getConstraint().getMarginX();
float ch = child.getBounds().getHeight() + 2 * child.getConstraint().getMarginY();
switch (getConstraint().getFlowDirection()) {
case LayoutConstraint.FLOW_NONE:
width = Math.max(width, cw);
height = Math.max(height, ch);
break;
case LayoutConstraint.FLOW_X:
width += cw;
height = Math.max(height, ch);
break;
case LayoutConstraint.FLOW_Y:
width = Math.max(width, cw);
height += ch;
break;
default:
throw new IllegalStateException("Unknown flow direction " + getConstraint().getFlowDirection());
}
}
if (getConstraint().getWidth() != 0) {
width = getConstraint().getWidth();
}
if (getConstraint().getHeight() != 0) {
height = getConstraint().getHeight();
}
setBounds(new Rectangle(0, 0, width, height));
} | Calculates the size based constraint width and height if present, otherwise from children sizes. |
public void setChildren(List<PrintComponent<?>> children) {
this.children = children;
// needed for Json unmarshall !!!!
for (PrintComponent<?> child : children) {
child.setParent(this);
}
} | Set child components.
@param children
children |
public void cache(Identity oid, Object obj)
{
doInternalCache(oid, obj, ObjectCacheInternal.TYPE_UNKNOWN);
} | Makes object persistent to the Objectcache.
I'm using soft-references to allow gc reclaim unused objects
even if they are still cached. |
public Object lookup(Identity oid)
{
processQueue();
hitCount++;
Object result = null;
CacheEntry entry = (CacheEntry) objectTable.get(buildKey(oid));
if(entry != null)
{
result = entry.get();
if(result == null || entry.getLifetime() < System.currentTimeMillis())
{
/*
cached object was removed by gc or lifetime was exhausted
remove CacheEntry from map
*/
gcCount++;
remove(oid);
// make sure that we return null
result = null;
}
else
{
/*
TODO: Not sure if this makes sense, could help to avoid corrupted objects
when changed in tx but not stored.
*/
traceIdentity(oid);
if(log.isDebugEnabled()) log.debug("Object match " + oid);
}
}
else
{
failCount++;
}
return result;
} | Lookup object with Identity oid in objectTable.
Returns null if no matching id is found |
public void remove(Identity oid)
{
//processQueue();
if(oid != null)
{
removeTracedIdentity(oid);
objectTable.remove(buildKey(oid));
if(log.isDebugEnabled()) log.debug("Remove object " + oid);
}
} | Removes an Object from the cache. |
public List<DbComment> getComments(String entityId, String entityType) {
return repositoryHandler.getComments(entityId, entityType);
} | Get a list of comments made for a particular entity
@param entityId - id of the commented entity
@param entityType - type of the entity
@return list of comments |
public void store(String gavc,
String action,
String commentText,
DbCredential credential,
String entityType) {
DbComment comment = new DbComment();
comment.setEntityId(gavc);
comment.setEntityType(entityType);
comment.setDbCommentedBy(credential.getUser());
comment.setAction(action);
if(!commentText.isEmpty()) {
comment.setDbCommentText(commentText);
}
comment.setDbCreatedDateTime(new Date());
repositoryHandler.store(comment);
} | Store a comment based on comment text, gavc and user information
@param gavc - entity id
@param commentText - comment text
@param credential - user credentials
@param entityType - type of the entity |
private boolean relevant(File currentLogFile, GregorianCalendar lastRelevantDate) {
String fileName=currentLogFile.getName();
Pattern p = Pattern.compile(APPENER_DATE_DEFAULT_PATTERN);
Matcher m = p.matcher(fileName);
if(m.find()){
int year=Integer.parseInt(m.group(1));
int month=Integer.parseInt(m.group(2));
int dayOfMonth=Integer.parseInt(m.group(3));
GregorianCalendar fileDate=new GregorianCalendar(year, month, dayOfMonth);
fileDate.add(Calendar.MONTH,-1); //Because of Calendar save the month such that January is 0
return fileDate.compareTo(lastRelevantDate)>0;
}
else{
return false;
}
} | Get a log file and last relevant date, and check if the log file is relevant
@param currentLogFile The log file
@param lastRelevantDate The last date which files should be keeping since
@return false if the file should be deleted, true if it does not. |
private GregorianCalendar getLastReleventDate(GregorianCalendar currentDate) {
int age=this.getProperties().getMaxFileAge();
GregorianCalendar result=new GregorianCalendar(currentDate.get(Calendar.YEAR),currentDate.get(Calendar.MONTH),currentDate.get(Calendar.DAY_OF_MONTH));
result.add(Calendar.DAY_OF_MONTH, -age);
return result;
} | Get the last date to keep logs from, by a given current date.
@param currentDate the date of today
@return the last date to keep log files from. |
private void addTableFor(ClassDescriptorDef classDef)
{
String name = classDef.getProperty(PropertyHelper.OJB_PROPERTY_TABLE);
TableDef tableDef = getTable(name);
FieldDescriptorDef fieldDef;
ReferenceDescriptorDef refDef;
CollectionDescriptorDef collDef;
ColumnDef columnDef;
IndexDef indexDef;
if (tableDef == null)
{
tableDef = new TableDef(name);
addTable(tableDef);
}
if (classDef.hasProperty(PropertyHelper.OJB_PROPERTY_DOCUMENTATION))
{
tableDef.setProperty(PropertyHelper.OJB_PROPERTY_DOCUMENTATION,
classDef.getProperty(PropertyHelper.OJB_PROPERTY_DOCUMENTATION));
}
if (classDef.hasProperty(PropertyHelper.OJB_PROPERTY_TABLE_DOCUMENTATION))
{
tableDef.setProperty(PropertyHelper.OJB_PROPERTY_TABLE_DOCUMENTATION,
classDef.getProperty(PropertyHelper.OJB_PROPERTY_TABLE_DOCUMENTATION));
}
for (Iterator fieldIt = classDef.getFields(); fieldIt.hasNext();)
{
fieldDef = (FieldDescriptorDef)fieldIt.next();
if (fieldDef.getBooleanProperty(PropertyHelper.OJB_PROPERTY_IGNORE, false) ||
fieldDef.getBooleanProperty(PropertyHelper.OJB_PROPERTY_VIRTUAL_FIELD, false))
{
continue;
}
columnDef = addColumnFor(fieldDef, tableDef);
if (fieldDef.getBooleanProperty(PropertyHelper.OJB_PROPERTY_INDEXED, false))
{
// add the field to the default index
indexDef = tableDef.getIndex(null);
if (indexDef == null)
{
indexDef = new IndexDef(null, false);
tableDef.addIndex(indexDef);
}
indexDef.addColumn(columnDef.getName());
}
}
for (Iterator refIt = classDef.getReferences(); refIt.hasNext();)
{
refDef = (ReferenceDescriptorDef)refIt.next();
if (!refDef.getBooleanProperty(PropertyHelper.OJB_PROPERTY_IGNORE, false))
{
addForeignkeys(refDef, tableDef);
}
}
for (Iterator collIt = classDef.getCollections(); collIt.hasNext();)
{
collDef = (CollectionDescriptorDef)collIt.next();
if (!collDef.getBooleanProperty(PropertyHelper.OJB_PROPERTY_IGNORE, false))
{
if (collDef.hasProperty(PropertyHelper.OJB_PROPERTY_INDIRECTION_TABLE))
{
addIndirectionTable(collDef);
}
else
{
addForeignkeys(collDef, tableDef);
}
}
}
for (Iterator indexIt = classDef.getIndexDescriptors(); indexIt.hasNext();)
{
addIndex((IndexDescriptorDef)indexIt.next(), tableDef);
}
} | Adds a table for the given class descriptor (if necessary).
@param classDef The class descriptor |
private ColumnDef addColumnFor(FieldDescriptorDef fieldDef, TableDef tableDef)
{
String name = fieldDef.getProperty(PropertyHelper.OJB_PROPERTY_COLUMN);
ColumnDef columnDef = tableDef.getColumn(name);
if (columnDef == null)
{
columnDef = new ColumnDef(name);
tableDef.addColumn(columnDef);
}
if (!fieldDef.isNested())
{
columnDef.setProperty(PropertyHelper.TORQUE_PROPERTY_JAVANAME, fieldDef.getName());
}
columnDef.setProperty(PropertyHelper.TORQUE_PROPERTY_TYPE, fieldDef.getProperty(PropertyHelper.OJB_PROPERTY_JDBC_TYPE));
columnDef.setProperty(PropertyHelper.TORQUE_PROPERTY_ID, fieldDef.getProperty(PropertyHelper.OJB_PROPERTY_ID));
if (fieldDef.getBooleanProperty(PropertyHelper.OJB_PROPERTY_PRIMARYKEY, false))
{
columnDef.setProperty(PropertyHelper.TORQUE_PROPERTY_PRIMARYKEY, "true");
columnDef.setProperty(PropertyHelper.TORQUE_PROPERTY_REQUIRED, "true");
}
else if (!fieldDef.getBooleanProperty(PropertyHelper.OJB_PROPERTY_NULLABLE, true))
{
columnDef.setProperty(PropertyHelper.TORQUE_PROPERTY_REQUIRED, "true");
}
if ("database".equals(fieldDef.getProperty(PropertyHelper.OJB_PROPERTY_AUTOINCREMENT)))
{
columnDef.setProperty(PropertyHelper.TORQUE_PROPERTY_AUTOINCREMENT, "true");
}
columnDef.setProperty(PropertyHelper.TORQUE_PROPERTY_SIZE, fieldDef.getSizeConstraint());
if (fieldDef.hasProperty(PropertyHelper.OJB_PROPERTY_DOCUMENTATION))
{
columnDef.setProperty(PropertyHelper.OJB_PROPERTY_DOCUMENTATION,
fieldDef.getProperty(PropertyHelper.OJB_PROPERTY_DOCUMENTATION));
}
if (fieldDef.hasProperty(PropertyHelper.OJB_PROPERTY_COLUMN_DOCUMENTATION))
{
columnDef.setProperty(PropertyHelper.OJB_PROPERTY_COLUMN_DOCUMENTATION,
fieldDef.getProperty(PropertyHelper.OJB_PROPERTY_COLUMN_DOCUMENTATION));
}
return columnDef;
} | Generates a column for the given field and adds it to the table.
@param fieldDef The field
@param tableDef The table
@return The column def |
private void addForeignkeys(ReferenceDescriptorDef refDef, TableDef tableDef)
{
if (!refDef.getBooleanProperty(PropertyHelper.OJB_PROPERTY_DATABASE_FOREIGNKEY, true))
{
// we shall not generate a database foreignkey
return;
}
// a foreignkey is added to the table schema if
// the referenced table exists (i.e. the referenced type has an associated table)
// then the foreignkey consists of:
// remote table = table of referenced type
// local fields = foreignkey fields of the reference
// remote fields = primarykeys of the referenced type
ClassDescriptorDef ownerClassDef = (ClassDescriptorDef)refDef.getOwner();
String targetClassName = refDef.getProperty(PropertyHelper.OJB_PROPERTY_CLASS_REF);
ClassDescriptorDef referencedClassDef = ((ModelDef)ownerClassDef.getOwner()).getClass(targetClassName);
// we can add a foreignkey only if the target type and all its subtypes either
// map to the same table or do not map to a table at all
String tableName = getHierarchyTable(referencedClassDef);
if (tableName == null)
{
return;
}
try
{
String name = refDef.getName();
ArrayList localFields = ownerClassDef.getFields(refDef.getProperty(PropertyHelper.OJB_PROPERTY_FOREIGNKEY));
ArrayList remoteFields = referencedClassDef.getPrimaryKeys();
tableDef.addForeignkey(name, tableName, getColumns(localFields), getColumns(remoteFields));
}
catch (NoSuchFieldException ex)
{
// won't happen if we already checked the constraints
}
} | Adds foreignkey(s) for the reference to the corresponding table(s).
@param refDef The reference
@param tableDef The table of the class owning the reference |
private void addForeignkeys(CollectionDescriptorDef collDef, TableDef tableDef)
{
if (!collDef.getBooleanProperty(PropertyHelper.OJB_PROPERTY_DATABASE_FOREIGNKEY, true))
{
// we shall not generate a database foreignkey
return;
}
// a foreignkey is added to the table schema if for both ends of the collection
// a table exists
// then the foreignkey consists of:
// remote table = table of collection owner
// local fields = foreignkey fields in the element type
// remote fields = primarykeys of the collection owner type
ClassDescriptorDef ownerClassDef = (ClassDescriptorDef)collDef.getOwner();
String elementClassName = collDef.getProperty(PropertyHelper.OJB_PROPERTY_ELEMENT_CLASS_REF);
ClassDescriptorDef elementClassDef = ((ModelDef)ownerClassDef.getOwner()).getClass(elementClassName);
// we can only generate foreignkeys if the collection itself is not shared by
// several classes in the hierarchy
for (Iterator it = ownerClassDef.getAllBaseTypes(); it.hasNext();)
{
if (containsCollectionAndMapsToDifferentTable(collDef, tableDef, (ClassDescriptorDef)it.next()))
{
return;
}
}
for (Iterator it = ownerClassDef.getAllExtentClasses(); it.hasNext();)
{
if (containsCollectionAndMapsToDifferentTable(collDef, tableDef, (ClassDescriptorDef)it.next()))
{
return;
}
}
// We add a foreignkey to all classes in the subtype hierarchy of the element type
// that map to a table (we're silently assuming that they contain the fk fields)
ArrayList candidates = new ArrayList();
if (elementClassDef.getBooleanProperty(PropertyHelper.OJB_PROPERTY_GENERATE_TABLE_INFO, true))
{
candidates.add(elementClassDef);
}
for (Iterator it = elementClassDef.getAllExtentClasses(); it.hasNext();)
{
ClassDescriptorDef curSubTypeDef = (ClassDescriptorDef)it.next();
if (curSubTypeDef.getBooleanProperty(PropertyHelper.OJB_PROPERTY_GENERATE_TABLE_INFO, true))
{
candidates.add(curSubTypeDef);
}
}
String name = collDef.getName();
ArrayList remoteFields = ownerClassDef.getPrimaryKeys();
HashMap processedTables = new HashMap();
for (Iterator it = candidates.iterator(); it.hasNext();)
{
elementClassDef = (ClassDescriptorDef)it.next();
try
{
// for the element class and its subclasses
String elementTableName = elementClassDef.getProperty(PropertyHelper.OJB_PROPERTY_TABLE);
// ensure that tables are only processed once
if (!processedTables.containsKey(elementTableName))
{
ArrayList localFields = elementClassDef.getFields(collDef.getProperty(PropertyHelper.OJB_PROPERTY_FOREIGNKEY));
TableDef elementTableDef = getTable(elementTableName);
if (elementTableDef == null)
{
elementTableDef = new TableDef(elementTableName);
addTable(elementTableDef);
}
elementTableDef.addForeignkey(name, tableDef.getName(), getColumns(localFields), getColumns(remoteFields));
processedTables.put(elementTableName, null);
}
}
catch (NoSuchFieldException ex)
{
// Shouldn't happen, but even if, then we're ignoring it and simply don't add the fk
}
}
} | Adds foreignkey(s) for the collection to the corresponding table(s).
@param collDef The collection
@param tableDef The table |
private List getColumns(List fields)
{
ArrayList columns = new ArrayList();
for (Iterator it = fields.iterator(); it.hasNext();)
{
FieldDescriptorDef fieldDef = (FieldDescriptorDef)it.next();
columns.add(fieldDef.getProperty(PropertyHelper.OJB_PROPERTY_COLUMN));
}
return columns;
} | Extracts the list of columns from the given field list.
@param fields The fields
@return The corresponding columns |
private boolean containsCollectionAndMapsToDifferentTable(CollectionDescriptorDef origCollDef, TableDef origTableDef, ClassDescriptorDef classDef)
{
if (classDef.getBooleanProperty(PropertyHelper.OJB_PROPERTY_GENERATE_TABLE_INFO, true) &&
!origTableDef.getName().equals(classDef.getProperty(PropertyHelper.OJB_PROPERTY_TABLE)))
{
CollectionDescriptorDef curCollDef = classDef.getCollection(origCollDef.getName());
if ((curCollDef != null) &&
!curCollDef.getBooleanProperty(PropertyHelper.OJB_PROPERTY_IGNORE, false))
{
return true;
}
}
return false;
} | Checks whether the given class maps to a different table but also has the given collection.
@param origCollDef The original collection to search for
@param origTableDef The original table
@param classDef The class descriptor to test
@return <code>true</code> if the class maps to a different table and has the collection |
private String getTargetTable(ClassDescriptorDef targetClassDef, String indirectionTable, String foreignKeys)
{
ModelDef modelDef = (ModelDef)targetClassDef.getOwner();
String tableName = null;
for (Iterator classIt = modelDef.getClasses(); classIt.hasNext();)
{
ClassDescriptorDef curClassDef = (ClassDescriptorDef)classIt.next();
if (!curClassDef.getBooleanProperty(PropertyHelper.OJB_PROPERTY_GENERATE_TABLE_INFO, true))
{
continue;
}
for (Iterator collIt = curClassDef.getCollections(); collIt.hasNext();)
{
CollectionDescriptorDef curCollDef = (CollectionDescriptorDef)collIt.next();
if (!indirectionTable.equals(curCollDef.getProperty(PropertyHelper.OJB_PROPERTY_INDIRECTION_TABLE)) ||
!CommaListIterator.sameLists(foreignKeys, curCollDef.getProperty(PropertyHelper.OJB_PROPERTY_FOREIGNKEY)))
{
continue;
}
// ok, collection fits
if (tableName != null)
{
if (!tableName.equals(curClassDef.getProperty(PropertyHelper.OJB_PROPERTY_TABLE)))
{
// maps to a different table
return null;
}
}
else
{
tableName = curClassDef.getProperty(PropertyHelper.OJB_PROPERTY_TABLE);
}
}
}
if (tableName == null)
{
// no fitting collection found -> indirection table with only one collection
// we have to check whether the hierarchy of the target class maps to one table only
return getHierarchyTable(targetClassDef);
}
else
{
return tableName;
}
} | Tries to return the single target table to which the given foreign key columns map in
all m:n collections that target this indirection table.
@param targetClassDef The original target class
@param indirectionTable The indirection table
@param foreignKeys The foreign keys columns in the indirection table pointing back to the
class' table
@return The table name or <code>null</code> if there is not exactly one table |
private String getHierarchyTable(ClassDescriptorDef classDef)
{
ArrayList queue = new ArrayList();
String tableName = null;
queue.add(classDef);
while (!queue.isEmpty())
{
ClassDescriptorDef curClassDef = (ClassDescriptorDef)queue.get(0);
queue.remove(0);
if (curClassDef.getBooleanProperty(PropertyHelper.OJB_PROPERTY_GENERATE_TABLE_INFO, true))
{
if (tableName != null)
{
if (!tableName.equals(curClassDef.getProperty(PropertyHelper.OJB_PROPERTY_TABLE)))
{
return null;
}
}
else
{
tableName = curClassDef.getProperty(PropertyHelper.OJB_PROPERTY_TABLE);
}
}
for (Iterator it = curClassDef.getExtentClasses(); it.hasNext();)
{
curClassDef = (ClassDescriptorDef)it.next();
if (curClassDef.getReference("super") == null)
{
queue.add(curClassDef);
}
}
}
return tableName;
} | Tries to return the single table to which all classes in the hierarchy with the given
class as the root map.
@param classDef The root class of the hierarchy
@return The table name or <code>null</code> if the classes map to more than one table
or no class in the hierarchy maps to a table |
private void addIndex(IndexDescriptorDef indexDescDef, TableDef tableDef)
{
IndexDef indexDef = tableDef.getIndex(indexDescDef.getName());
if (indexDef == null)
{
indexDef = new IndexDef(indexDescDef.getName(),
indexDescDef.getBooleanProperty(PropertyHelper.OJB_PROPERTY_UNIQUE, false));
tableDef.addIndex(indexDef);
}
try
{
String fieldNames = indexDescDef.getProperty(PropertyHelper.OJB_PROPERTY_FIELDS);
ArrayList fields = ((ClassDescriptorDef)indexDescDef.getOwner()).getFields(fieldNames);
FieldDescriptorDef fieldDef;
for (Iterator it = fields.iterator(); it.hasNext();)
{
fieldDef = (FieldDescriptorDef)it.next();
indexDef.addColumn(fieldDef.getProperty(PropertyHelper.OJB_PROPERTY_COLUMN));
}
}
catch (NoSuchFieldException ex)
{
// won't happen if we already checked the constraints
}
} | Adds an index to the table for the given index descriptor.
@param indexDescDef The index descriptor
@param tableDef The table |
private void addIndirectionTable(CollectionDescriptorDef collDef)
{
String tableName = collDef.getProperty(PropertyHelper.OJB_PROPERTY_INDIRECTION_TABLE);
TableDef tableDef = getTable(tableName);
if (tableDef == null)
{
tableDef = new TableDef(tableName);
addTable(tableDef);
}
if (collDef.hasProperty(PropertyHelper.OJB_PROPERTY_INDIRECTION_TABLE_DOCUMENTATION))
{
tableDef.setProperty(PropertyHelper.OJB_PROPERTY_TABLE_DOCUMENTATION,
collDef.getProperty(PropertyHelper.OJB_PROPERTY_INDIRECTION_TABLE_DOCUMENTATION));
}
// we add columns for every primarykey in this and the element type
// collection.foreignkeys <-> ownerclass.primarykeys
// collection.remote-foreignkeys <-> elementclass.primarykeys
// we also add foreignkeys to the table
// name is empty (default foreignkey)
// remote table = table of ownerclass/elementclass
// local columns = columns in indirection table
// remote columns = columns of corresponding primarykeys in ownerclass/elementclass
ClassDescriptorDef ownerClassDef = (ClassDescriptorDef)collDef.getOwner();
ModelDef modelDef = (ModelDef)ownerClassDef.getOwner();
String elementClassName = collDef.getProperty(PropertyHelper.OJB_PROPERTY_ELEMENT_CLASS_REF);
ClassDescriptorDef elementClassDef = modelDef.getClass(elementClassName);
ArrayList localPrimFields = ownerClassDef.getPrimaryKeys();
ArrayList remotePrimFields = elementClassDef.getPrimaryKeys();
String localKeyList = collDef.getProperty(PropertyHelper.OJB_PROPERTY_FOREIGNKEY);
String remoteKeyList = collDef.getProperty(PropertyHelper.OJB_PROPERTY_REMOTE_FOREIGNKEY);
String ownerTable = getTargetTable(ownerClassDef, tableName, localKeyList);
String elementTable = getTargetTable(elementClassDef, tableName, remoteKeyList);
CommaListIterator localKeys = new CommaListIterator(localKeyList);
CommaListIterator localKeyDocs = new CommaListIterator(collDef.getProperty(PropertyHelper.OJB_PROPERTY_FOREIGNKEY_DOCUMENTATION));
CommaListIterator remoteKeys = new CommaListIterator(remoteKeyList);
CommaListIterator remoteKeyDocs = new CommaListIterator(collDef.getProperty(PropertyHelper.OJB_PROPERTY_REMOTE_FOREIGNKEY_DOCUMENTATION));
ArrayList localColumns = new ArrayList();
ArrayList remoteColumns = new ArrayList();
boolean asPrimarykeys = collDef.getBooleanProperty(PropertyHelper.OJB_PROPERTY_INDIRECTION_TABLE_PRIMARYKEYS, false);
FieldDescriptorDef fieldDef;
ColumnDef columnDef;
String relationName;
String name;
int idx;
for (idx = 0; localKeys.hasNext(); idx++)
{
fieldDef = (FieldDescriptorDef)localPrimFields.get(idx);
name = localKeys.getNext();
columnDef = tableDef.getColumn(name);
if (columnDef == null)
{
columnDef = new ColumnDef(name);
tableDef.addColumn(columnDef);
}
columnDef.setProperty(PropertyHelper.TORQUE_PROPERTY_TYPE, fieldDef.getProperty(PropertyHelper.OJB_PROPERTY_JDBC_TYPE));
columnDef.setProperty(PropertyHelper.TORQUE_PROPERTY_SIZE, fieldDef.getSizeConstraint());
if (asPrimarykeys)
{
columnDef.setProperty(PropertyHelper.TORQUE_PROPERTY_PRIMARYKEY, "true");
}
if (localKeyDocs.hasNext())
{
columnDef.setProperty(PropertyHelper.OJB_PROPERTY_COLUMN_DOCUMENTATION, localKeyDocs.getNext());
}
localColumns.add(name);
remoteColumns.add(fieldDef.getProperty(PropertyHelper.OJB_PROPERTY_COLUMN));
}
if (collDef.getBooleanProperty(PropertyHelper.OJB_PROPERTY_DATABASE_FOREIGNKEY, true))
{
relationName = collDef.getProperty(PropertyHelper.TORQUE_PROPERTY_RELATION_NAME);
if ((relationName != null) && (ownerTable != null))
{
tableDef.addForeignkey(relationName, ownerTable, localColumns, remoteColumns);
}
}
localColumns.clear();
remoteColumns.clear();
for (idx = 0; remoteKeys.hasNext(); idx++)
{
fieldDef = (FieldDescriptorDef)remotePrimFields.get(idx);
name = remoteKeys.getNext();
columnDef = tableDef.getColumn(name);
if (columnDef == null)
{
columnDef = new ColumnDef(name);
tableDef.addColumn(columnDef);
}
columnDef.setProperty(PropertyHelper.TORQUE_PROPERTY_TYPE, fieldDef.getProperty(PropertyHelper.OJB_PROPERTY_JDBC_TYPE));
columnDef.setProperty(PropertyHelper.TORQUE_PROPERTY_SIZE, fieldDef.getSizeConstraint());
if (asPrimarykeys)
{
columnDef.setProperty(PropertyHelper.TORQUE_PROPERTY_PRIMARYKEY, "true");
}
if (remoteKeyDocs.hasNext())
{
columnDef.setProperty(PropertyHelper.OJB_PROPERTY_COLUMN_DOCUMENTATION, remoteKeyDocs.getNext());
}
localColumns.add(name);
remoteColumns.add(fieldDef.getProperty(PropertyHelper.OJB_PROPERTY_COLUMN));
}
CollectionDescriptorDef elementCollDef = collDef.getRemoteCollection();
if (((elementCollDef != null) && elementCollDef.getBooleanProperty(PropertyHelper.OJB_PROPERTY_DATABASE_FOREIGNKEY, true)) ||
((elementCollDef == null) && collDef.getBooleanProperty(PropertyHelper.OJB_PROPERTY_DATABASE_FOREIGNKEY, true)))
{
relationName = collDef.getProperty(PropertyHelper.TORQUE_PROPERTY_INV_RELATION_NAME);
if ((relationName != null) && (elementTable != null))
{
tableDef.addForeignkey(relationName, elementTable, localColumns, remoteColumns);
}
}
} | Adds the indirection table for the given collection descriptor.
@param collDef The collection descriptor |
private void addTable(TableDef table)
{
table.setOwner(this);
_tableDefs.put(table.getName(), table);
} | Adds a table to this model.
@param table The table |
public static Class getClass(String name) throws ClassNotFoundException
{
try
{
return Class.forName(name);
}
catch (ClassNotFoundException ex)
{
throw new ClassNotFoundException(name);
}
} | Retrieves the class object for the class with the given name.
@param name The class name
@return The class object
@throws ClassNotFoundException If the class is not on the classpath (the exception message contains the class name) |
public boolean isSameOrSubTypeOf(XClass type, String baseType, boolean checkActualClasses) throws ClassNotFoundException
{
String qualifiedBaseType = baseType.replace('$', '.');
if (type.getQualifiedName().equals(qualifiedBaseType))
{
return true;
}
// first search via XDoclet
ArrayList queue = new ArrayList();
boolean canSpecify = false;
XClass curType;
queue.add(type);
while (!queue.isEmpty())
{
curType = (XClass)queue.get(0);
queue.remove(0);
if (qualifiedBaseType.equals(curType.getQualifiedName()))
{
return true;
}
if (curType.getInterfaces() != null)
{
for (Iterator it = curType.getInterfaces().iterator(); it.hasNext(); )
{
queue.add(it.next());
}
}
if (!curType.isInterface())
{
if (curType.getSuperclass() != null)
{
queue.add(curType.getSuperclass());
}
}
}
// if not found, we try via actual classes
return checkActualClasses ? isSameOrSubTypeOf(type.getQualifiedName(), qualifiedBaseType) : false;
} | Determines whether the given type is the same or a sub type of the other type.
@param type The type
@param baseType The possible base type
@param checkActualClasses Whether to use the actual classes for the test
@return <code>true</code> If <code>type</code> specifies the same or a sub type of <code>baseType</code>
@throws ClassNotFoundException If the two classes are not on the classpath |
public boolean isSameOrSubTypeOf(ClassDescriptorDef type, String baseType, boolean checkActualClasses) throws ClassNotFoundException
{
if (type.getQualifiedName().equals(baseType.replace('$', '.')))
{
return true;
}
else if (type.getOriginalClass() != null)
{
return isSameOrSubTypeOf(type.getOriginalClass(), baseType, checkActualClasses);
}
else
{
return checkActualClasses ? isSameOrSubTypeOf(type.getName(), baseType) : false;
}
} | Determines whether the given type is the same or a sub type of the other type.
@param type The type
@param baseType The possible base type
@param checkActualClasses Whether to use the actual classes for the test
@return <code>true</code> If <code>type</code> specifies the same or a sub type of <code>baseType</code>
@throws ClassNotFoundException If the two classes are not on the classpath |
public boolean isSameOrSubTypeOf(String type, String baseType) throws ClassNotFoundException
{
return type.replace('$', '.').equals(baseType.replace('$', '.')) ? true : isSameOrSubTypeOf(getClass(type), baseType);
} | Determines whether the given type is the same or a sub type of the other type.
@param type The type
@param baseType The possible base type
@return <code>true</code> If <code>type</code> specifies the same or a sub type of <code>baseType</code>
@throws ClassNotFoundException If the two classes are not on the classpath |
public boolean isSameOrSubTypeOf(Class type, String baseType) throws ClassNotFoundException
{
return type.getName().equals(baseType.replace('$', '.')) ? true : getClass(baseType).isAssignableFrom(type);
} | Determines whether the given type is the same or a sub type of the other type.
@param type The type
@param baseType The possible base type
@return <code>true</code> If <code>type</code> specifies the same or a sub type of <code>baseType</code>
@throws ClassNotFoundException If the two classes are not on the classpath |
public void cache(Identity oid, Object obj)
{
if (oid != null && obj != null)
{
ObjectCache cache = getCache(oid, obj, METHOD_CACHE);
if (cache != null)
{
cache.cache(oid, obj);
}
}
} | Caches the given object using the given Identity as key
@param oid The Identity key
@param obj The object o cache |
public Object lookup(Identity oid)
{
Object ret = null;
if (oid != null)
{
ObjectCache cache = getCache(oid, null, METHOD_LOOKUP);
if (cache != null)
{
ret = cache.lookup(oid);
}
}
return ret;
} | Looks up the object from the cache
@param oid The Identity to look up the object for
@return The object if found, otherwise null |
public void remove(Identity oid)
{
if (oid == null) return;
ObjectCache cache = getCache(oid, null, METHOD_REMOVE);
if (cache != null)
{
cache.remove(oid);
}
} | Removes the given object from the cache
@param oid oid of the object to remove |
public static ResourceBundle getCurrentResourceBundle(String locale) {
try {
if (null != locale && !locale.isEmpty()) {
return getCurrentResourceBundle(LocaleUtils.toLocale(locale));
}
} catch (IllegalArgumentException ex) {
// do nothing
}
return getCurrentResourceBundle((Locale) null);
} | Returns the resource bundle for current Locale, i.e. locale set in the PageComponent.
Always create a new instance, this avoids getting the incorrect locale information.
@return resourcebundle for internationalized messages |
public int compare(Object objA, Object objB)
{
if (!(objA instanceof DefBase) || !(objB instanceof DefBase))
{
return 0;
}
else
{
return ((DefBase)objA).getName().compareTo(((DefBase)objB).getName());
}
} | /* (non-Javadoc)
@see java.util.Comparator#compare(java.lang.Object, java.lang.Object) |
public Object visit(And filter, Object userData) {
Criterion c = null;
for (Filter element : filter.getChildren()) {
if (c == null) {
c = (Criterion) element.accept(this, userData);
} else {
c = Restrictions.and(c, (Criterion) element.accept(this, userData));
}
}
return c;
} | {@inheritDoc} |
@Override
public Object visit(Not filter, Object userData) {
Criterion c = (Criterion) filter.getFilter().accept(this, userData);
return Restrictions.not(c);
} | {@inheritDoc} |
@Override
public Object visit(Or filter, Object userData) {
Criterion c = null;
for (Filter element : filter.getChildren()) {
if (c == null) {
c = (Criterion) element.accept(this, userData);
} else {
c = Restrictions.or(c, (Criterion) element.accept(this, userData));
}
}
return c;
} | {@inheritDoc} |
@Override
public Object visit(PropertyIsBetween filter, Object userData) {
String propertyName = getPropertyName(filter.getExpression());
String finalName = parsePropertyName(propertyName, userData);
Object lo = castLiteral(getLiteralValue(filter.getLowerBoundary()), propertyName);
Object hi = castLiteral(getLiteralValue(filter.getUpperBoundary()), propertyName);
return Restrictions.between(finalName, lo, hi);
} | {@inheritDoc} |
@Override
public Object visit(PropertyIsEqualTo filter, Object userData) {
String propertyName = getPropertyName(filter.getExpression1());
String finalName = parsePropertyName(propertyName, userData);
Object value = castLiteral(getLiteralValue(filter.getExpression2()), propertyName);
return Restrictions.eq(finalName, value);
} | {@inheritDoc} |
@Override
public Object visit(PropertyIsGreaterThanOrEqualTo filter, Object userData) {
String propertyName = getPropertyName(filter.getExpression1());
String finalName = parsePropertyName(propertyName, userData);
Object literal = getLiteralValue(filter.getExpression2());
return Restrictions.ge(finalName, castLiteral(literal, propertyName));
} | {@inheritDoc} |
@Override
public Object visit(PropertyIsLike filter, Object userData) {
String propertyName = getPropertyName(filter.getExpression());
String finalName = parsePropertyName(propertyName, userData);
String value = filter.getLiteral();
value = value.replaceAll("\\*", "%");
value = value.replaceAll("\\?", "_");
if (filter.isMatchingCase()) {
return Restrictions.like(finalName, value);
} else {
return Restrictions.ilike(finalName, value);
}
} | {@inheritDoc} |
@Override
public Object visit(PropertyIsNull filter, Object userData) {
String propertyName = getPropertyName(filter.getExpression());
String finalName = parsePropertyName(propertyName, userData);
return Restrictions.isNull(finalName);
} | {@inheritDoc} |
@Override
public Object visit(BBOX filter, Object userData) {
Envelope env = new Envelope(filter.getMinX(), filter.getMaxX(), filter.getMinY(), filter.getMaxY());
String finalName = parsePropertyName(geomName, userData);
return SpatialRestrictions.filter(finalName, env, srid);
} | {@inheritDoc} |
@Override
public Object visit(Intersects filter, Object userData) {
String finalName = parsePropertyName(geomName, userData);
return SpatialRestrictions.intersects(finalName, asGeometry(getLiteralValue(filter.getExpression2())));
} | {@inheritDoc} |
@Override
public Object visit(Overlaps filter, Object userData) {
String finalName = parsePropertyName(geomName, userData);
return SpatialRestrictions.overlaps(finalName, asGeometry(getLiteralValue(filter.getExpression2())));
} | {@inheritDoc} |
@Override
public Object visit(Touches filter, Object userData) {
String finalName = parsePropertyName(geomName, userData);
return SpatialRestrictions.touches(finalName, asGeometry(getLiteralValue(filter.getExpression2())));
} | {@inheritDoc} |
@Override
public Object visit(Within filter, Object userData) {
String finalName = parsePropertyName(geomName, userData);
return SpatialRestrictions.within(finalName, asGeometry(getLiteralValue(filter.getExpression2())));
} | {@inheritDoc} |
@Override
public Object visit(ExcludeFilter filter, Object userData) {
return Restrictions.not(Restrictions.conjunction());
} | {@inheritDoc} |
@Override
public Object visit(Id filter, Object userData) {
String idName;
try {
idName = featureModel.getEntityMetadata().getIdentifierPropertyName();
} catch (LayerException e) {
log.warn("Cannot read idName, defaulting to 'id'", e);
idName = HIBERNATE_ID;
}
Collection<?> c = (Collection<?>) castLiteral(filter.getIdentifiers(), idName);
return Restrictions.in(idName, c);
} | {@inheritDoc} |
@Override
public Object visit(After after, Object extraData) {
String propertyName = getPropertyName(after.getExpression1());
String finalName = parsePropertyName(propertyName, after);
Object literal = getLiteralValue(after.getExpression2());
if (literal instanceof Date) {
return Restrictions.gt(finalName, literal);
} else {
throw new UnsupportedOperationException("visit(Object userData)");
}
} | {@inheritDoc} |
@Override
public Object visit(Before before, Object extraData) {
String propertyName = getPropertyName(before.getExpression1());
String finalName = parsePropertyName(propertyName, before);
Object literal = getLiteralValue(before.getExpression2());
if (literal instanceof Date) {
return Restrictions.lt(finalName, literal);
} else {
throw new UnsupportedOperationException("visit(Object userData)");
}
} | {@inheritDoc} |
@Override
public Object visit(During during, Object userData) {
String propertyName = getPropertyName(during.getExpression1());
String finalName = parsePropertyName(propertyName, userData);
Object literal = getLiteralValue(during.getExpression2());
if (literal instanceof Period) {
Period p = (Period) literal;
Date begin = p.getBeginning().getPosition().getDate();
Date end = p.getEnding().getPosition().getDate();
return Restrictions.between(finalName, begin, end);
} else {
throw new UnsupportedOperationException("visit(Object userData)");
}
} | {@inheritDoc} |
private String getPropertyName(Expression expression) {
if (!(expression instanceof PropertyName)) {
throw new IllegalArgumentException("Expression " + expression + " is not a PropertyName.");
}
String name = ((PropertyName) expression).getPropertyName();
if (name.endsWith(FilterService.ATTRIBUTE_ID)) {
// replace by Hibernate id property, always refers to the id, even if named differently
name = name.substring(0, name.length() - FilterService.ATTRIBUTE_ID.length()) + HIBERNATE_ID;
}
return name;
} | Get the property name from the expression.
@param expression expression
@return property name |
private Object getLiteralValue(Expression expression) {
if (!(expression instanceof Literal)) {
throw new IllegalArgumentException("Expression " + expression + " is not a Literal.");
}
return ((Literal) expression).getValue();
} | Get the literal value for an expression.
@param expression expression
@return literal value |
private String parsePropertyName(String orgPropertyName, Object userData) {
// try to assure the correct separator is used
String propertyName = orgPropertyName.replace(HibernateLayerUtil.XPATH_SEPARATOR, HibernateLayerUtil.SEPARATOR);
// split the path (separator is defined in the HibernateLayerUtil)
String[] props = propertyName.split(HibernateLayerUtil.SEPARATOR_REGEXP);
String finalName;
if (props.length > 1 && userData instanceof Criteria) {
// the criteria API requires an alias for each join table !!!
String prevAlias = null;
for (int i = 0; i < props.length - 1; i++) {
String alias = props[i] + "_alias";
if (!aliases.contains(alias)) {
Criteria criteria = (Criteria) userData;
if (i == 0) {
criteria.createAlias(props[0], alias);
} else {
criteria.createAlias(prevAlias + "." + props[i], alias);
}
aliases.add(alias);
}
prevAlias = alias;
}
finalName = prevAlias + "." + props[props.length - 1];
} else {
finalName = propertyName;
}
return finalName;
} | Go through the property name to see if it is a complex one. If it is, aliases must be declared.
@param orgPropertyName
The propertyName. Can be complex.
@param userData
The userData object that is passed in each method of the FilterVisitor. Should always be of the info
"Criteria".
@return property name |
private Object castLiteral(Object literal, String propertyName) {
try {
if (literal instanceof Collection) {
return castCollection(literal, propertyName);
}
if (literal instanceof Object[]) {
return castObjectArray(literal, propertyName);
}
Class<?> clazz = featureModel.getPropertyClass(featureModel.getEntityMetadata(), propertyName);
if (!clazz.equals(literal.getClass())) {
if (clazz.equals(Boolean.class)) {
return Boolean.valueOf(literal.toString());
} else if (clazz.equals(Date.class)) {
dateFormat.parse(literal.toString());
} else if (clazz.equals(Double.class)) {
return Double.valueOf(literal.toString());
} else if (clazz.equals(Float.class)) {
return Float.valueOf(literal.toString());
} else if (clazz.equals(Integer.class)) {
return Integer.valueOf(literal.toString());
} else if (clazz.equals(Long.class)) {
return Long.valueOf(literal.toString());
} else if (clazz.equals(Short.class)) {
return Short.valueOf(literal.toString());
} else if (clazz.equals(String.class)) {
return literal.toString();
}
}
} catch (Exception e) { // NOSONAR
log.error(e.getMessage(), e);
}
return literal;
} | Literals from filters do not always have the right class (i.e. integer instead of long). This function can cast
those objects.
@param literal
The literal object that needs casting to the correct class.
@param propertyName
The name of the property. Only by knowing what property we're talking about, can we derive it's class
from the Hibernate metadata.
@return Always returns a value! |
public void afterCompletion(int status)
{
if(afterCompletionCall) return;
log.info("Method afterCompletion was called");
try
{
switch(status)
{
case Status.STATUS_COMMITTED:
if(log.isDebugEnabled())
{
log.debug("Method afterCompletion: Do commit internal odmg-tx, status of JTA-tx is " + TxUtil.getStatusString(status));
}
commit();
break;
default:
log.error("Method afterCompletion: Do abort call on internal odmg-tx, status of JTA-tx is " + TxUtil.getStatusString(status));
abort();
}
}
finally
{
afterCompletionCall = true;
log.info("Method afterCompletion finished");
}
} | FOR internal use. This method was called after the external transaction was completed.
@see javax.transaction.Synchronization |
public void beforeCompletion()
{
// avoid redundant calls
if(beforeCompletionCall) return;
log.info("Method beforeCompletion was called");
int status = Status.STATUS_UNKNOWN;
try
{
JTATxManager mgr = (JTATxManager) getImplementation().getTxManager();
status = mgr.getJTATransaction().getStatus();
// ensure proper work, check all possible status
// normally only check for 'STATUS_MARKED_ROLLBACK' is necessary
if(status == Status.STATUS_MARKED_ROLLBACK
|| status == Status.STATUS_ROLLEDBACK
|| status == Status.STATUS_ROLLING_BACK
|| status == Status.STATUS_UNKNOWN
|| status == Status.STATUS_NO_TRANSACTION)
{
log.error("Synchronization#beforeCompletion: Can't prepare for commit, because tx status was "
+ TxUtil.getStatusString(status) + ". Do internal cleanup only.");
}
else
{
if(log.isDebugEnabled())
{
log.debug("Synchronization#beforeCompletion: Prepare for commit");
}
// write objects to database
prepareCommit();
}
}
catch(Exception e)
{
log.error("Synchronization#beforeCompletion: Error while prepare for commit", e);
if(e instanceof LockNotGrantedException)
{
throw (LockNotGrantedException) e;
}
else if(e instanceof TransactionAbortedException)
{
throw (TransactionAbortedException) e;
}
else if(e instanceof ODMGRuntimeException)
{
throw (ODMGRuntimeException) e;
}
else
{
throw new ODMGRuntimeException("Method beforeCompletion() fails, status of JTA-tx was "
+ TxUtil.getStatusString(status) + ", message: " + e.getMessage());
}
}
finally
{
beforeCompletionCall = true;
setInExternTransaction(false);
internalCleanup();
}
} | FOR internal use. This method was called before the external transaction was completed.
This method was called by the JTA-TxManager before the JTA-tx prepare call. Within this method
we prepare odmg for commit and pass all modified persistent objects to DB and release/close the used
connection. We have to close the connection in this method, because the TxManager does prepare for commit
after this method and all used DataSource-connections have to be closed before.
@see javax.transaction.Synchronization |
private void internalCleanup()
{
if(hasBroker())
{
PersistenceBroker broker = getBroker();
if(log.isDebugEnabled())
{
log.debug("Do internal cleanup and close the internal used connection without" +
" closing the used broker");
}
ConnectionManagerIF cm = broker.serviceConnectionManager();
if(cm.isInLocalTransaction())
{
/*
arminw:
in managed environment this call will be ignored because, the JTA transaction
manager control the connection status. But to make connectionManager happy we
have to complete the "local tx" of the connectionManager before release the
connection
*/
cm.localCommit();
}
cm.releaseConnection();
}
} | In managed environment do internal close the used connection |
public void applyDefaults() {
if (fillColor == null) {
fillColor = "#ffffff"; // white
}
if (strokeColor == null) {
strokeColor = "#000000"; // black
}
if (strokeOpacity == -1) {
strokeOpacity = 1; // fully opaque by default
}
if (fillOpacity == -1) {
fillOpacity = .5f; // 50% transparent by default
}
if (strokeWidth == -1) {
strokeWidth = 1; // white
}
if (symbol == null) { // circle with radius 10 by default
symbol = new SymbolInfo();
}
if (symbol.getCircle() == null && symbol.getRect() == null && symbol.getImage() == null) {
symbol.setCircle(new CircleInfo());
symbol.getCircle().setR(10);
}
} | Applies default values to all properties that have not been set.
@since 1.8.0 |
public String getCacheId() {
return "FeatureStyleInfo{" + "index=" + index + ", name='" + name + '\'' + ", formula='" + formula + '\''
+ ", fillColor='" + fillColor + '\'' + ", fillOpacity=" + fillOpacity + ", strokeColor='" + strokeColor
+ '\'' + ", strokeOpacity=" + strokeOpacity + ", strokeWidth=" + strokeWidth + ", dashArray='"
+ dashArray + '\'' + ", symbol=" + symbol + ", styleId='" + styleId + '\'' + '}';
} | String identifier which is guaranteed to include sufficient information to assure to be different for two
instances which could produce different result. It is typically used as basis for calculation of hash codes (like
MD5, SHA1, SHA2 etc) of (collections of) objects.
@return cacheId
@since 1.8.0 |
public void checkpoint(ObjectEnvelope mod)
throws org.apache.ojb.broker.PersistenceBrokerException
{
mod.doUpdate();
} | checkpoint the transaction |
@Api
public void setUrl(String url) throws LayerException {
try {
this.url = url;
Map<String, Object> params = new HashMap<String, Object>();
params.put("url", url);
DataStore store = DataStoreFactory.create(params);
setDataStore(store);
} catch (IOException ioe) {
throw new LayerException(ioe, ExceptionCode.INVALID_SHAPE_FILE_URL, url);
}
} | Set the url for the shape file.
@param url shape file url
@throws LayerException file cannot be accessed
@since 1.7.1 |
public Iterator<?> getElements(Filter filter, int offset, int maxResultSize) throws LayerException {
List<SimpleFeature> filteredList = new ArrayList<SimpleFeature>();
for (SimpleFeature feature : features.values()) {
if (filter.evaluate(feature)) {
filteredList.add(feature);
if (filteredList.size() == maxResultSize) {
break;
}
}
}
return filteredList.iterator();
} | {@inheritDoc}
This implementation does not support the 'offset' and 'maxResultSize' parameters. |
public Envelope getBounds(Filter filter) throws LayerException {
try {
FeatureCollection<SimpleFeatureType, SimpleFeature> fc = getFeatureSource().getFeatures(filter);
return fc.getBounds();
} catch (IOException ioe) {
throw new LayerException(ioe, ExceptionCode.FEATURE_MODEL_PROBLEM);
}
} | Retrieve the bounds of the specified features.
@param filter filter
@return the bounds of the specified features
@throws LayerException cannot read features |
@PostConstruct
protected void initFeatures() throws LayerException {
crs = geoService.getCrs2(layerInfo.getCrs());
try {
setFeatureSourceName(layerInfo.getFeatureInfo().getDataSourceName());
featureModel = new ShapeInMemFeatureModel(getDataStore(), layerInfo.getFeatureInfo().getDataSourceName(),
geoService.getSridFromCrs(layerInfo.getCrs()), converterService);
featureModel.setLayerInfo(layerInfo);
FeatureCollection<SimpleFeatureType, SimpleFeature> col = getFeatureSource().getFeatures();
FeatureIterator<SimpleFeature> iterator = col.features();
int lastIndex = 0;
while (iterator.hasNext()) {
SimpleFeature feature = iterator.next();
String id = featureModel.getId(feature);
features.put(id, feature);
int intId = Integer.parseInt(id.substring(id.lastIndexOf('.') + 1));
if (intId > lastIndex) {
lastIndex = intId;
}
}
iterator.close();
((ShapeInMemFeatureModel) featureModel).setNextId(++lastIndex);
} catch (NumberFormatException nfe) {
throw new LayerException(nfe, ExceptionCode.FEATURE_MODEL_PROBLEM, url);
} catch (MalformedURLException e) {
throw new LayerException(e, ExceptionCode.INVALID_SHAPE_FILE_URL, url);
} catch (IOException ioe) {
throw new LayerException(ioe, ExceptionCode.CANNOT_CREATE_LAYER_MODEL, url);
} catch (GeomajasException ge) {
throw new LayerException(ge, ExceptionCode.CANNOT_CREATE_LAYER_MODEL, url);
}
} | Finish initializing the layer.
@throws LayerException oops |
private Object getUserObject(Identity oid, Object cacheObject)
{
Object userObject = _editingContext.lookup(oid);
if (userObject == null)
{
ObjectCopyStrategy copyStrategy = _tx.getKit().getCopyStrategy(oid);
userObject = copyStrategy.copy(cacheObject, _pb);
}
return userObject;
} | Get user object (from the editing context) with the given oid.
If not found, then create it as a copy of cacheObject.
User object and cache object must be separate.
@param oid The identity
@param cacheObject the object for user |
@POST
public Response postLicense(@Auth final DbCredential credential, final License license){
if(!credential.getRoles().contains(AvailableRoles.DATA_UPDATER)){
throw new WebApplicationException(Response.status(Response.Status.UNAUTHORIZED).build());
}
LOG.info("Got a post license request.");
//
// Checks if the data is corrupted, pattern can be compiled etc.
//
DataValidator.validate(license);
// Save the license
final DbLicense dbLicense = getModelMapper().getDbLicense(license);
//
// The store method will deal with making sure there are no pattern conflicts
// The reason behind this move is the presence of the instance of RepositoryHandler
// and the imposibility to access that handler from here.
//
getLicenseHandler().store(dbLicense);
cacheUtils.clear(CacheName.PROMOTION_REPORTS);
return Response.ok().status(HttpStatus.CREATED_201).build();
} | Handle license posts when the server got a request POST <dm_url>/license & MIME that contains the license.
@param license The license to add to Grapes database
@return Response An acknowledgment:<br/>- 400 if the artifact is MIME is malformed<br/>- 500 if internal error<br/>- 201 if ok |
@GET
@Produces({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON})
@Path(ServerAPI.GET_NAMES)
public Response getNames(@Context final UriInfo uriInfo){
LOG.info("Got a get license names request.");
final ListView view = new ListView("License names view", "license");
final FiltersHolder filters = new FiltersHolder();
filters.init(uriInfo.getQueryParameters());
final List<String> names = getLicenseHandler().getLicensesNames(filters);
view.addAll(names);
return Response.ok(view).build();
} | Return the list of available license name.
This method is call via GET <dm_url>/license/names
@param uriInfo UriInfo
@return Response A list of license name in HTML or JSON |
@GET
@Produces({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON})
@Path("/{name}")
public Response get(@PathParam("name") final String name){
LOG.info("Got a get license request.");
final LicenseView view = new LicenseView();
final DbLicense dbLicense = getLicenseHandler().getLicense(name);
final License license = getModelMapper().getLicense(dbLicense);
view.setLicense(license);
return Response.ok(view).build();
} | Return a license
This method is call via GET <dm_url>/license/<name>
@param name String
@return Response A license in HTML or JSON |
@DELETE
@Produces({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON})
@Path("/{name}")
public Response delete(@Auth final DbCredential credential, @PathParam("name") final String name){
if(!credential.getRoles().contains(AvailableRoles.DATA_DELETER)){
throw new WebApplicationException(Response.status(Response.Status.UNAUTHORIZED).build());
}
LOG.info("Got a delete license request.");
getLicenseHandler().deleteLicense(name);
cacheUtils.clear(CacheName.PROMOTION_REPORTS);
return Response.ok("done").build();
} | Delete a license
This method is call via DELETE <dm_url>/license/<name>
@param credential DbCredential
@param name String
@return Response |
@POST
@Produces({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON})
@Path("/{name}")
public Response approve(@Auth final DbCredential credential, @PathParam("name") final String name, @QueryParam(ServerAPI.APPROVED_PARAM) final BooleanParam approved){
if(!credential.getRoles().contains(AvailableRoles.LICENSE_CHECKER)){
throw new WebApplicationException(Response.status(Response.Status.UNAUTHORIZED).build());
}
LOG.info("Got a get license request.");
if(approved == null){
return Response.serverError().status(HttpStatus.NOT_ACCEPTABLE_406).build();
}
getLicenseHandler().approveLicense(name, approved.get());
cacheUtils.clear(CacheName.PROMOTION_REPORTS);
return Response.ok("done").build();
} | Validate a license
This method is call via POST <dm_url>/license/<name>?approved=<boolean>
@param credential DbCredential
@param name String
@param approved BooleanParam
@return Response |
public void setEditorTarget (PropertyEditorTarget target)
{
if (target instanceof DBMetaSchemaNode)
{
super.setEditorTarget(target);
this.tfSchemaName.setText((String)target.getAttribute(DBMetaSchemaNode.ATT_SCHEMA_NAME));
}
else
{
throw new UnsupportedOperationException("This editor can only edit DBSchemaCatalogNode objects");
}
} | GEN-END:initComponents |
private void initComponents()//GEN-BEGIN:initComponents
{
java.awt.GridBagConstraints gridBagConstraints;
lblDatabaseAlias = new javax.swing.JLabel();
tfDatabaseAlias = new org.apache.ojb.tools.mapping.reversedb2.propertyEditors.PropertyEditorJTextField();
lblDBMS = new javax.swing.JLabel();
tfDBMS = new org.apache.ojb.tools.mapping.reversedb2.propertyEditors.PropertyEditorJTextField();
lblDatasourceName = new javax.swing.JLabel();
tfDatasourceName = new org.apache.ojb.tools.mapping.reversedb2.propertyEditors.PropertyEditorJTextField();
lblDriver = new javax.swing.JLabel();
tfDriver = new org.apache.ojb.tools.mapping.reversedb2.propertyEditors.PropertyEditorJTextField();
lblDescriptorKey = new javax.swing.JLabel();
tfDescriptorKey = new org.apache.ojb.tools.mapping.reversedb2.propertyEditors.PropertyEditorJTextField();
lblJDBCLevel = new javax.swing.JLabel();
tfJDBCLevel = new org.apache.ojb.tools.mapping.reversedb2.propertyEditors.PropertyEditorJTextField();
tfPassword = new org.apache.ojb.tools.mapping.reversedb2.propertyEditors.PropertyEditorJTextField();
lblPassword = new javax.swing.JLabel();
lblProtocol = new javax.swing.JLabel();
tfProtocol = new org.apache.ojb.tools.mapping.reversedb2.propertyEditors.PropertyEditorJTextField();
lblSubProtocol = new javax.swing.JLabel();
tfSubProtocol = new org.apache.ojb.tools.mapping.reversedb2.propertyEditors.PropertyEditorJTextField();
tfUsername = new org.apache.ojb.tools.mapping.reversedb2.propertyEditors.PropertyEditorJTextField();
lblUsername = new javax.swing.JLabel();
setLayout(new java.awt.GridBagLayout());
lblDatabaseAlias.setDisplayedMnemonic('a');
lblDatabaseAlias.setLabelFor(tfDatabaseAlias);
lblDatabaseAlias.setText("Database Alias:");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 1;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
add(lblDatabaseAlias, gridBagConstraints);
tfDatabaseAlias.setText("jTextField1");
tfDatabaseAlias.setEditorKey(org.apache.ojb.tools.mapping.reversedb2.ojbmetatreemodel.OjbMetaJdbcConnectionDescriptorNode.ATT_DBALIAS);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 1;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
gridBagConstraints.weightx = 1.0;
add(tfDatabaseAlias, gridBagConstraints);
lblDBMS.setDisplayedMnemonic('d');
lblDBMS.setLabelFor(tfDBMS);
lblDBMS.setText("DBMS:");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 2;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
add(lblDBMS, gridBagConstraints);
tfDBMS.setText("jTextField1");
tfDBMS.setEditorKey(org.apache.ojb.tools.mapping.reversedb2.ojbmetatreemodel.OjbMetaJdbcConnectionDescriptorNode.ATT_DBMS);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
gridBagConstraints.weightx = 1.0;
add(tfDBMS, gridBagConstraints);
lblDatasourceName.setDisplayedMnemonic('n');
lblDatasourceName.setLabelFor(tfDatasourceName);
lblDatasourceName.setText("Datasource Name:");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 3;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
add(lblDatasourceName, gridBagConstraints);
tfDatasourceName.setText("jTextField1");
tfDatasourceName.setEditorKey(org.apache.ojb.tools.mapping.reversedb2.ojbmetatreemodel.OjbMetaJdbcConnectionDescriptorNode.ATT_DATASOURCE_NAME);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 3;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
gridBagConstraints.weightx = 1.0;
add(tfDatasourceName, gridBagConstraints);
lblDriver.setDisplayedMnemonic('r');
lblDriver.setLabelFor(tfDriver);
lblDriver.setText("Driver:");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 4;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
add(lblDriver, gridBagConstraints);
tfDriver.setText("jTextField1");
tfDriver.setEditorKey(org.apache.ojb.tools.mapping.reversedb2.ojbmetatreemodel.OjbMetaJdbcConnectionDescriptorNode.ATT_DRIVER);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 4;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
gridBagConstraints.weightx = 1.0;
add(tfDriver, gridBagConstraints);
lblDescriptorKey.setDisplayedMnemonic('k');
lblDescriptorKey.setLabelFor(tfDescriptorKey);
lblDescriptorKey.setText("Descriptor Key:");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 5;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
add(lblDescriptorKey, gridBagConstraints);
tfDescriptorKey.setText("jTextField1");
tfDescriptorKey.setEditorKey(org.apache.ojb.tools.mapping.reversedb2.ojbmetatreemodel.OjbMetaJdbcConnectionDescriptorNode.ATT_DESCRIPTOR_PBKEY);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 5;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
gridBagConstraints.weightx = 1.0;
add(tfDescriptorKey, gridBagConstraints);
lblJDBCLevel.setDisplayedMnemonic('J');
lblJDBCLevel.setLabelFor(tfJDBCLevel);
lblJDBCLevel.setText("JDBC Level:");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 6;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
add(lblJDBCLevel, gridBagConstraints);
tfJDBCLevel.setText("jTextField1");
tfJDBCLevel.setEditorKey(org.apache.ojb.tools.mapping.reversedb2.ojbmetatreemodel.OjbMetaJdbcConnectionDescriptorNode.ATT_JDBC_LEVEL);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 6;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
gridBagConstraints.weightx = 1.0;
add(tfJDBCLevel, gridBagConstraints);
tfPassword.setText("jTextField1");
tfPassword.setEditorKey(org.apache.ojb.tools.mapping.reversedb2.ojbmetatreemodel.OjbMetaJdbcConnectionDescriptorNode.ATT_PASSWORD);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 7;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
gridBagConstraints.weightx = 1.0;
add(tfPassword, gridBagConstraints);
lblPassword.setDisplayedMnemonic('p');
lblPassword.setLabelFor(tfPassword);
lblPassword.setText("Password:");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 7;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
add(lblPassword, gridBagConstraints);
lblProtocol.setDisplayedMnemonic('o');
lblProtocol.setLabelFor(tfProtocol);
lblProtocol.setText("Protocol:");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 8;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
add(lblProtocol, gridBagConstraints);
tfProtocol.setText("jTextField1");
tfProtocol.setEditorKey(org.apache.ojb.tools.mapping.reversedb2.ojbmetatreemodel.OjbMetaJdbcConnectionDescriptorNode.ATT_PROTOCOL);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 8;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
gridBagConstraints.weightx = 1.0;
add(tfProtocol, gridBagConstraints);
lblSubProtocol.setDisplayedMnemonic('s');
lblSubProtocol.setLabelFor(tfSubProtocol);
lblSubProtocol.setText("Sub Protocol:");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 9;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
add(lblSubProtocol, gridBagConstraints);
tfSubProtocol.setText("jTextField1");
tfSubProtocol.setEditorKey(org.apache.ojb.tools.mapping.reversedb2.ojbmetatreemodel.OjbMetaJdbcConnectionDescriptorNode.ATT_SUBPROTOCOL);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 9;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
gridBagConstraints.weightx = 1.0;
add(tfSubProtocol, gridBagConstraints);
tfUsername.setText("jTextField1");
tfUsername.setEditorKey(org.apache.ojb.tools.mapping.reversedb2.ojbmetatreemodel.OjbMetaJdbcConnectionDescriptorNode.ATT_USERNAME);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 10;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
gridBagConstraints.weightx = 1.0;
gridBagConstraints.weighty = 1.0;
add(tfUsername, gridBagConstraints);
lblUsername.setDisplayedMnemonic('m');
lblUsername.setLabelFor(tfUsername);
lblUsername.setText("Username:");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 10;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
gridBagConstraints.weighty = 1.0;
add(lblUsername, gridBagConstraints);
} | This method is called from within the constructor to
initialize the form.
WARNING: Do NOT modify this code. The content of this method is
always regenerated by the Form Editor. |
private void beginInternTransaction()
{
if (log.isDebugEnabled()) log.debug("beginInternTransaction was called");
J2EETransactionImpl tx = (J2EETransactionImpl) super.currentTransaction();
if (tx == null) tx = newInternTransaction();
if (!tx.isOpen())
{
// start the transaction
tx.begin();
tx.setInExternTransaction(true);
}
} | Here we start a intern odmg-Transaction to hide transaction demarcation
This method could be invoked several times within a transaction, but only
the first call begin a intern odmg transaction |
private J2EETransactionImpl newInternTransaction()
{
if (log.isDebugEnabled()) log.debug("obtain new intern odmg-transaction");
J2EETransactionImpl tx = new J2EETransactionImpl(this);
try
{
getConfigurator().configure(tx);
}
catch (ConfigurationException e)
{
throw new OJBRuntimeException("Cannot create new intern odmg transaction", e);
}
return tx;
} | Returns a new intern odmg-transaction for the current database. |
public ObjectPool createConnectionPool(JdbcConnectionDescriptor jcd)
{
if (log.isDebugEnabled()) log.debug("createPool was called");
PoolableObjectFactory pof = new ConPoolFactory(this, jcd);
GenericObjectPool.Config conf = jcd.getConnectionPoolDescriptor().getObjectPoolConfig();
return (ObjectPool)new GenericObjectPool(pof, conf);
} | Create the pool for pooling the connections of the given connection descriptor.
Override this method to implement your on {@link org.apache.commons.pool.ObjectPool}. |
public void releaseAllResources()
{
synchronized (poolSynch)
{
Collection pools = poolMap.values();
poolMap = new HashMap(poolMap.size());
ObjectPool op = null;
for (Iterator iterator = pools.iterator(); iterator.hasNext();)
{
try
{
op = ((ObjectPool) iterator.next());
op.close();
}
catch (Exception e)
{
log.error("Exception occured while closing pool " + op, e);
}
}
}
super.releaseAllResources();
} | Closes all managed pools. |
protected void associateBatched(Collection owners, Collection children)
{
ObjectReferenceDescriptor ord = getObjectReferenceDescriptor();
ClassDescriptor cld = getOwnerClassDescriptor();
Object owner;
Object relatedObject;
Object fkValues[];
Identity id;
PersistenceBroker pb = getBroker();
PersistentField field = ord.getPersistentField();
Class topLevelClass = pb.getTopLevelClass(ord.getItemClass());
HashMap childrenMap = new HashMap(children.size());
for (Iterator it = children.iterator(); it.hasNext(); )
{
relatedObject = it.next();
childrenMap.put(pb.serviceIdentity().buildIdentity(relatedObject), relatedObject);
}
for (Iterator it = owners.iterator(); it.hasNext(); )
{
owner = it.next();
fkValues = ord.getForeignKeyValues(owner,cld);
if (isNull(fkValues))
{
field.set(owner, null);
continue;
}
id = pb.serviceIdentity().buildIdentity(null, topLevelClass, fkValues);
relatedObject = childrenMap.get(id);
field.set(owner, relatedObject);
}
} | Associate the batched Children with their owner object.
Loop over owners |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.