_id
stringlengths
2
7
title
stringlengths
3
140
partition
stringclasses
3 values
text
stringlengths
73
34.1k
language
stringclasses
1 value
meta_information
dict
q9100
ClassDescriptorConstraints.checkModifications
train
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); } } } }
java
{ "resource": "" }
q9101
ClassDescriptorConstraints.checkExtents
train
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); } }
java
{ "resource": "" }
q9102
ClassDescriptorConstraints.checkInitializationMethod
train
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"); } }
java
{ "resource": "" }
q9103
ClassDescriptorConstraints.checkPrimaryKey
train
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"); } }
java
{ "resource": "" }
q9104
ClassDescriptorConstraints.checkRowReader
train
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()); } }
java
{ "resource": "" }
q9105
ClassDescriptorConstraints.checkObjectCache
train
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()); } }
java
{ "resource": "" }
q9106
ClassDescriptorConstraints.checkProcedures
train
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); } } } } }
java
{ "resource": "" }
q9107
OTMJCAManagedConnection.getConnection
train
OTMConnection getConnection() { if (m_connection == null) { OTMConnectionRuntimeException ex = new OTMConnectionRuntimeException("Connection is null."); sendEvents(ConnectionEvent.CONNECTION_ERROR_OCCURRED, ex, null); } return m_connection; }
java
{ "resource": "" }
q9108
Version.getReleaseId
train
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; }
java
{ "resource": "" }
q9109
Version.compare
train
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; }
java
{ "resource": "" }
q9110
PrintComponentImpl.calculateSize
train
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)); }
java
{ "resource": "" }
q9111
PrintComponentImpl.setChildren
train
public void setChildren(List<PrintComponent<?>> children) { this.children = children; // needed for Json unmarshall !!!! for (PrintComponent<?> child : children) { child.setParent(this); } }
java
{ "resource": "" }
q9112
ObjectCacheDefaultImpl.remove
train
public void remove(Identity oid) { //processQueue(); if(oid != null) { removeTracedIdentity(oid); objectTable.remove(buildKey(oid)); if(log.isDebugEnabled()) log.debug("Remove object " + oid); } }
java
{ "resource": "" }
q9113
CommentHandler.getComments
train
public List<DbComment> getComments(String entityId, String entityType) { return repositoryHandler.getComments(entityId, entityType); }
java
{ "resource": "" }
q9114
CommentHandler.store
train
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); }
java
{ "resource": "" }
q9115
HistoryLogFileScavenger.relevant
train
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; } }
java
{ "resource": "" }
q9116
HistoryLogFileScavenger.getLastReleventDate
train
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; }
java
{ "resource": "" }
q9117
TorqueModelDef.addColumnFor
train
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; }
java
{ "resource": "" }
q9118
TorqueModelDef.getColumns
train
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; }
java
{ "resource": "" }
q9119
TorqueModelDef.containsCollectionAndMapsToDifferentTable
train
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; }
java
{ "resource": "" }
q9120
TorqueModelDef.getHierarchyTable
train
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; }
java
{ "resource": "" }
q9121
TorqueModelDef.addIndex
train
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 } }
java
{ "resource": "" }
q9122
TorqueModelDef.addTable
train
private void addTable(TableDef table) { table.setOwner(this); _tableDefs.put(table.getName(), table); }
java
{ "resource": "" }
q9123
InheritanceHelper.getClass
train
public static Class getClass(String name) throws ClassNotFoundException { try { return Class.forName(name); } catch (ClassNotFoundException ex) { throw new ClassNotFoundException(name); } }
java
{ "resource": "" }
q9124
AbstractMetaCache.cache
train
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); } } }
java
{ "resource": "" }
q9125
AbstractMetaCache.lookup
train
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; }
java
{ "resource": "" }
q9126
AbstractMetaCache.remove
train
public void remove(Identity oid) { if (oid == null) return; ObjectCache cache = getCache(oid, null, METHOD_REMOVE); if (cache != null) { cache.remove(oid); } }
java
{ "resource": "" }
q9127
ComponentUtil.getCurrentResourceBundle
train
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); }
java
{ "resource": "" }
q9128
CriteriaVisitor.getPropertyName
train
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; }
java
{ "resource": "" }
q9129
CriteriaVisitor.getLiteralValue
train
private Object getLiteralValue(Expression expression) { if (!(expression instanceof Literal)) { throw new IllegalArgumentException("Expression " + expression + " is not a Literal."); } return ((Literal) expression).getValue(); }
java
{ "resource": "" }
q9130
CriteriaVisitor.parsePropertyName
train
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; }
java
{ "resource": "" }
q9131
J2EETransactionImpl.afterCompletion
train
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"); } }
java
{ "resource": "" }
q9132
J2EETransactionImpl.beforeCompletion
train
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(); } }
java
{ "resource": "" }
q9133
J2EETransactionImpl.internalCleanup
train
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(); } }
java
{ "resource": "" }
q9134
StateOldDirty.checkpoint
train
public void checkpoint(ObjectEnvelope mod) throws org.apache.ojb.broker.PersistenceBrokerException { mod.doUpdate(); }
java
{ "resource": "" }
q9135
ShapeInMemLayer.setUrl
train
@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); } }
java
{ "resource": "" }
q9136
ImplementationJTAImpl.beginInternTransaction
train
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); } }
java
{ "resource": "" }
q9137
ImplementationJTAImpl.newInternTransaction
train
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; }
java
{ "resource": "" }
q9138
ReferencePrefetcher.associateBatched
train
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); } }
java
{ "resource": "" }
q9139
DListImpl.existsElement
train
public boolean existsElement(String predicate) throws org.odmg.QueryInvalidException { DList results = (DList) this.query(predicate); if (results == null || results.size() == 0) return false; else return true; }
java
{ "resource": "" }
q9140
DListImpl.select
train
public Iterator select(String predicate) throws org.odmg.QueryInvalidException { return this.query(predicate).iterator(); }
java
{ "resource": "" }
q9141
DListImpl.selectElement
train
public Object selectElement(String predicate) throws org.odmg.QueryInvalidException { return ((DList) this.query(predicate)).get(0); }
java
{ "resource": "" }
q9142
CommaListIterator.sameLists
train
public static boolean sameLists(String list1, String list2) { return new CommaListIterator(list1).equals(new CommaListIterator(list2)); }
java
{ "resource": "" }
q9143
TransactionLogger.startTimer
train
public static void startTimer(final String type) { TransactionLogger instance = getInstance(); if (instance == null) { return; } instance.components.putIfAbsent(type, new Component(type)); instance.components.get(type).startTimer(); }
java
{ "resource": "" }
q9144
TransactionLogger.pauseTimer
train
public static void pauseTimer(final String type) { TransactionLogger instance = getInstance(); if (instance == null) { return; } instance.components.get(type).pauseTimer(); }
java
{ "resource": "" }
q9145
TransactionLogger.getComponentsMultiThread
train
public static ComponentsMultiThread getComponentsMultiThread() { TransactionLogger instance = getInstance(); if (instance == null) { return null; } return instance.componentsMultiThread; }
java
{ "resource": "" }
q9146
TransactionLogger.getComponentsList
train
public static Collection<Component> getComponentsList() { TransactionLogger instance = getInstance(); if (instance == null) { return null; } return instance.components.values(); }
java
{ "resource": "" }
q9147
TransactionLogger.getFlowContext
train
public static String getFlowContext() { TransactionLogger instance = getInstance(); if (instance == null) { return null; } return instance.flowContext; }
java
{ "resource": "" }
q9148
TransactionLogger.createLoggingAction
train
protected static boolean createLoggingAction(final Logger logger, final Logger auditor, final TransactionLogger instance) { TransactionLogger oldInstance = getInstance(); if (oldInstance == null || oldInstance.finished) { if(loggingKeys == null) { synchronized (TransactionLogger.class) { if (loggingKeys == null) { logger.info("Initializing 'LoggingKeysHandler' class"); loggingKeys = new LoggingKeysHandler(keysPropStream); } } } initInstance(instance, logger, auditor); setInstance(instance); return true; } return false; // Really not sure it can happen - since we arrive here in a new thread of transaction I think it's ThreadLocal should be empty. But leaving this code just in case... }
java
{ "resource": "" }
q9149
TransactionLogger.addPropertiesStart
train
protected void addPropertiesStart(String type) { putProperty(PropertyKey.Host.name(), IpUtils.getHostName()); putProperty(PropertyKey.Type.name(), type); putProperty(PropertyKey.Status.name(), Status.Start.name()); }
java
{ "resource": "" }
q9150
TransactionLogger.writePropertiesToLog
train
protected void writePropertiesToLog(Logger logger, Level level) { writeToLog(logger, level, getMapAsString(this.properties, separator), null); if (this.exception != null) { writeToLog(this.logger, Level.ERROR, "Error:", this.exception); } }
java
{ "resource": "" }
q9151
TransactionLogger.initInstance
train
private static void initInstance(final TransactionLogger instance, final Logger logger, final Logger auditor) { instance.logger = logger; instance.auditor = auditor; instance.components = new LinkedHashMap<>(); instance.properties = new LinkedHashMap<>(); instance.total = new Component(TOTAL_COMPONENT); instance.total.startTimer(); instance.componentsMultiThread = new ComponentsMultiThread(); instance.flowContext = FlowContextFactory.serializeNativeFlowContext(); }
java
{ "resource": "" }
q9152
TransactionLogger.writeToLog
train
private static void writeToLog(Logger logger, Level level, String pattern, Exception exception) { if (level == Level.ERROR) { logger.error(pattern, exception); } else if (level == Level.INFO) { logger.info(pattern); } else if (level == Level.DEBUG) { logger.debug(pattern); } }
java
{ "resource": "" }
q9153
TransactionLogger.addTimePerComponent
train
private static void addTimePerComponent(HashMap<String, Long> mapComponentTimes, Component component) { Long currentTimeOfComponent = 0L; String key = component.getComponentType(); if (mapComponentTimes.containsKey(key)) { currentTimeOfComponent = mapComponentTimes.get(key); } //when transactions are run in parallel, we should log the longest transaction only to avoid that //for ex 'Total time' would be 100ms and transactions in parallel to hornetQ will be 2000ms Long maxTime = Math.max(component.getTime(), currentTimeOfComponent); mapComponentTimes.put(key, maxTime); }
java
{ "resource": "" }
q9154
ExtendedLikeFilterImpl.convertToSQL92
train
public static String convertToSQL92(char escape, char multi, char single, String pattern) throws IllegalArgumentException { if ((escape == '\'') || (multi == '\'') || (single == '\'')) { throw new IllegalArgumentException("do not use single quote (') as special char!"); } StringBuilder result = new StringBuilder(pattern.length() + 5); int i = 0; while (i < pattern.length()) { char chr = pattern.charAt(i); if (chr == escape) { // emit the next char and skip it if (i != (pattern.length() - 1)) { result.append(pattern.charAt(i + 1)); } i++; // skip next char } else if (chr == single) { result.append('_'); } else if (chr == multi) { result.append('%'); } else if (chr == '\'') { result.append('\''); result.append('\''); } else { result.append(chr); } i++; } return result.toString(); }
java
{ "resource": "" }
q9155
ExtendedLikeFilterImpl.getSQL92LikePattern
train
public String getSQL92LikePattern() throws IllegalArgumentException { if (escape.length() != 1) { throw new IllegalArgumentException("Like Pattern --> escape char should be of length exactly 1"); } if (wildcardSingle.length() != 1) { throw new IllegalArgumentException("Like Pattern --> wildcardSingle char should be of length exactly 1"); } if (wildcardMulti.length() != 1) { throw new IllegalArgumentException("Like Pattern --> wildcardMulti char should be of length exactly 1"); } return LikeFilterImpl.convertToSQL92(escape.charAt(0), wildcardMulti.charAt(0), wildcardSingle.charAt(0), isMatchingCase(), pattern); }
java
{ "resource": "" }
q9156
ExtendedLikeFilterImpl.evaluate
train
public boolean evaluate(Object feature) { // Checks to ensure that the attribute has been set if (attribute == null) { return false; } // Note that this converts the attribute to a string // for comparison. Unlike the math or geometry filters, which // require specific types to function correctly, this filter // using the mandatory string representation in Java // Of course, this does not guarantee a meaningful result, but it // does guarantee a valid result. // LOGGER.finest("pattern: " + pattern); // LOGGER.finest("string: " + attribute.getValue(feature)); // return attribute.getValue(feature).toString().matches(pattern); Object value = attribute.evaluate(feature); if (null == value) { return false; } Matcher matcher = getMatcher(); matcher.reset(value.toString()); return matcher.matches(); }
java
{ "resource": "" }
q9157
ExtendedLikeFilterImpl.isSpecial
train
private boolean isSpecial(final char chr) { return ((chr == '.') || (chr == '?') || (chr == '*') || (chr == '^') || (chr == '$') || (chr == '+') || (chr == '[') || (chr == ']') || (chr == '(') || (chr == ')') || (chr == '|') || (chr == '\\') || (chr == '&')); }
java
{ "resource": "" }
q9158
ExtendedLikeFilterImpl.fixSpecials
train
private String fixSpecials(final String inString) { StringBuilder tmp = new StringBuilder(); for (int i = 0; i < inString.length(); i++) { char chr = inString.charAt(i); if (isSpecial(chr)) { tmp.append(this.escape); tmp.append(chr); } else { tmp.append(chr); } } return tmp.toString(); }
java
{ "resource": "" }
q9159
StatementsForClassImpl.prepareStatement
train
protected PreparedStatement prepareStatement(Connection con, String sql, boolean scrollable, boolean createPreparedStatement, int explicitFetchSizeHint) throws SQLException { PreparedStatement result; // if a JDBC1.0 driver is used the signature // prepareStatement(String, int, int) is not defined. // we then call the JDBC1.0 variant prepareStatement(String) try { // if necessary use JDB1.0 methods if (!FORCEJDBC1_0) { if (createPreparedStatement) { result = con.prepareStatement( sql, scrollable ? ResultSet.TYPE_SCROLL_INSENSITIVE : ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); afterJdbc2CapableStatementCreate(result, explicitFetchSizeHint); } else { result = con.prepareCall( sql, scrollable ? ResultSet.TYPE_SCROLL_INSENSITIVE : ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); } } else { if (createPreparedStatement) { result = con.prepareStatement(sql); } else { result = con.prepareCall(sql); } } } catch (AbstractMethodError err) { // this exception is raised if Driver is not JDBC 2.0 compliant log.warn("Used driver seems not JDBC 2.0 compatible, use the JDBC 1.0 mode", err); if (createPreparedStatement) { result = con.prepareStatement(sql); } else { result = con.prepareCall(sql); } FORCEJDBC1_0 = true; } catch (SQLException eSql) { // there are JDBC Driver that nominally implement JDBC 2.0, but // throw DriverNotCapableExceptions. If we catch one of these // we force usage of JDBC 1.0 if (eSql .getClass() .getName() .equals("interbase.interclient.DriverNotCapableException")) { log.warn("JDBC 2.0 problems with this interbase driver, we use the JDBC 1.0 mode"); if (createPreparedStatement) { result = con.prepareStatement(sql); } else { result = con.prepareCall(sql); } FORCEJDBC1_0 = true; } else { throw eSql; } } try { if (!ProxyHelper.isNormalOjbProxy(result)) // tomdz: What about VirtualProxy { platform.afterStatementCreate(result); } } catch (PlatformException e) { log.error("Platform dependend failure", e); } return result; }
java
{ "resource": "" }
q9160
StatementsForClassImpl.createStatement
train
private Statement createStatement(Connection con, boolean scrollable, int explicitFetchSizeHint) throws java.sql.SQLException { Statement result; try { // if necessary use JDBC1.0 methods if (!FORCEJDBC1_0) { result = con.createStatement( scrollable ? ResultSet.TYPE_SCROLL_INSENSITIVE : ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); afterJdbc2CapableStatementCreate(result, explicitFetchSizeHint); } else { result = con.createStatement(); } } catch (AbstractMethodError err) { // if a JDBC1.0 driver is used, the signature // createStatement(int, int) is not defined. // we then call the JDBC1.0 variant createStatement() log.warn("Used driver seems not JDBC 2.0 compatible, use the JDBC 1.0 mode", err); result = con.createStatement(); FORCEJDBC1_0 = true; } catch (SQLException eSql) { // there are JDBC Driver that nominally implement JDBC 2.0, but // throw DriverNotCapableExceptions. If we catch one of these // we force usage of JDBC 1.0 if (eSql.getClass().getName() .equals("interbase.interclient.DriverNotCapableException")) { log.warn("JDBC 2.0 problems with this interbase driver, we use the JDBC 1.0 mode"); FORCEJDBC1_0 = true; result = con.createStatement(); } else { throw eSql; } } try { platform.afterStatementCreate(result); } catch (PlatformException e) { log.error("Platform dependend failure", e); } return result; }
java
{ "resource": "" }
q9161
InternalFeatureImpl.compareTo
train
public int compareTo(InternalFeature o) { if (null == o) { return -1; // avoid NPE, put null objects at the end } if (null != styleDefinition && null != o.getStyleInfo()) { if (styleDefinition.getIndex() > o.getStyleInfo().getIndex()) { return 1; } if (styleDefinition.getIndex() < o.getStyleInfo().getIndex()) { return -1; } } return 0; }
java
{ "resource": "" }
q9162
AbstractLogFileScavenger.begin
train
public final void begin() { this.file = this.getAppender().getIoFile(); if (this.file == null) { this.getAppender().getErrorHandler() .error("Scavenger not started: missing log file name"); return; } if (this.getProperties().getScavengeInterval() > -1) { final Thread thread = new Thread(this, "Log4J File Scavenger"); thread.setDaemon(true); thread.start(); this.threadRef = thread; } }
java
{ "resource": "" }
q9163
AbstractLogFileScavenger.end
train
public final void end() { final Thread thread = threadRef; if (thread != null) { thread.interrupt(); try { thread.join(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } this.threadRef = null; }
java
{ "resource": "" }
q9164
PropertyHelper.isPropertyAllowed
train
public static boolean isPropertyAllowed(Class defClass, String propertyName) { HashMap props = (HashMap)_properties.get(defClass); return (props == null ? true : props.containsKey(propertyName)); }
java
{ "resource": "" }
q9165
PropertyHelper.toBoolean
train
public static boolean toBoolean(String value, boolean defaultValue) { return "true".equals(value) ? true : ("false".equals(value) ? false : defaultValue); }
java
{ "resource": "" }
q9166
SqlQueryStatement.getFieldDescriptor
train
protected FieldDescriptor getFieldDescriptor(TableAlias aTableAlias, PathInfo aPathInfo) { FieldDescriptor fld = null; String colName = aPathInfo.column; if (aTableAlias != null) { fld = aTableAlias.cld.getFieldDescriptorByName(colName); if (fld == null) { ObjectReferenceDescriptor ord = aTableAlias.cld.getObjectReferenceDescriptorByName(colName); if (ord != null) { fld = getFldFromReference(aTableAlias, ord); } else { fld = getFldFromJoin(aTableAlias, colName); } } } return fld; }
java
{ "resource": "" }
q9167
SqlQueryStatement.getFldFromJoin
train
private FieldDescriptor getFldFromJoin(TableAlias aTableAlias, String aColName) { FieldDescriptor fld = null; // Search Join Structure for attribute if (aTableAlias.joins != null) { Iterator itr = aTableAlias.joins.iterator(); while (itr.hasNext()) { Join join = (Join) itr.next(); ClassDescriptor cld = join.right.cld; if (cld != null) { fld = cld.getFieldDescriptorByName(aColName); if (fld != null) { break; } } } } return fld; }
java
{ "resource": "" }
q9168
SqlQueryStatement.getFldFromReference
train
private FieldDescriptor getFldFromReference(TableAlias aTableAlias, ObjectReferenceDescriptor anOrd) { FieldDescriptor fld = null; if (aTableAlias == getRoot()) { // no path expression FieldDescriptor[] fk = anOrd.getForeignKeyFieldDescriptors(aTableAlias.cld); if (fk.length > 0) { fld = fk[0]; } } else { // attribute with path expression /** * MBAIRD * potentially people are referring to objects, not to the object's primary key, * and then we need to take the primary key attribute of the referenced object * to help them out. */ ClassDescriptor cld = aTableAlias.cld.getRepository().getDescriptorFor(anOrd.getItemClass()); if (cld != null) { fld = aTableAlias.cld.getFieldDescriptorByName(cld.getPkFields()[0].getPersistentField().getName()); } } return fld; }
java
{ "resource": "" }
q9169
SqlQueryStatement.ensureColumns
train
protected void ensureColumns(List columns, List existingColumns) { if (columns == null || columns.isEmpty()) { return; } Iterator iter = columns.iterator(); while (iter.hasNext()) { FieldHelper cf = (FieldHelper) iter.next(); if (!existingColumns.contains(cf.name)) { getAttributeInfo(cf.name, false, null, getQuery().getPathClasses()); } } }
java
{ "resource": "" }
q9170
SqlQueryStatement.appendWhereClause
train
protected void appendWhereClause(StringBuffer where, Criteria crit, StringBuffer stmt) { if (where.length() == 0) { where = null; } if (where != null || (crit != null && !crit.isEmpty())) { stmt.append(" WHERE "); appendClause(where, crit, stmt); } }
java
{ "resource": "" }
q9171
SqlQueryStatement.appendHavingClause
train
protected void appendHavingClause(StringBuffer having, Criteria crit, StringBuffer stmt) { if (having.length() == 0) { having = null; } if (having != null || crit != null) { stmt.append(" HAVING "); appendClause(having, crit, stmt); } }
java
{ "resource": "" }
q9172
SqlQueryStatement.appendBetweenCriteria
train
private void appendBetweenCriteria(TableAlias alias, PathInfo pathInfo, BetweenCriteria c, StringBuffer buf) { appendColName(alias, pathInfo, c.isTranslateAttribute(), buf); buf.append(c.getClause()); appendParameter(c.getValue(), buf); buf.append(" AND "); appendParameter(c.getValue2(), buf); }
java
{ "resource": "" }
q9173
SqlQueryStatement.getIndirectionTableColName
train
private String getIndirectionTableColName(TableAlias mnAlias, String path) { int dotIdx = path.lastIndexOf("."); String column = path.substring(dotIdx); return mnAlias.alias + column; }
java
{ "resource": "" }
q9174
SqlQueryStatement.appendLikeCriteria
train
private void appendLikeCriteria(TableAlias alias, PathInfo pathInfo, LikeCriteria c, StringBuffer buf) { appendColName(alias, pathInfo, c.isTranslateAttribute(), buf); buf.append(c.getClause()); appendParameter(c.getValue(), buf); buf.append(m_platform.getEscapeClause(c)); }
java
{ "resource": "" }
q9175
SqlQueryStatement.appendSQLClause
train
protected void appendSQLClause(SelectionCriteria c, StringBuffer buf) { // BRJ : handle SqlCriteria if (c instanceof SqlCriteria) { buf.append(c.getAttribute()); return; } // BRJ : criteria attribute is a query if (c.getAttribute() instanceof Query) { Query q = (Query) c.getAttribute(); buf.append("("); buf.append(getSubQuerySQL(q)); buf.append(")"); buf.append(c.getClause()); appendParameter(c.getValue(), buf); return; } AttributeInfo attrInfo = getAttributeInfo((String) c.getAttribute(), false, c.getUserAlias(), c.getPathClasses()); TableAlias alias = attrInfo.tableAlias; if (alias != null) { boolean hasExtents = alias.hasExtents(); if (hasExtents) { // BRJ : surround with braces if alias has extents buf.append("("); appendCriteria(alias, attrInfo.pathInfo, c, buf); c.setNumberOfExtentsToBind(alias.extents.size()); Iterator iter = alias.iterateExtents(); while (iter.hasNext()) { TableAlias tableAlias = (TableAlias) iter.next(); buf.append(" OR "); appendCriteria(tableAlias, attrInfo.pathInfo, c, buf); } buf.append(")"); } else { // no extents appendCriteria(alias, attrInfo.pathInfo, c, buf); } } else { // alias null appendCriteria(alias, attrInfo.pathInfo, c, buf); } }
java
{ "resource": "" }
q9176
SqlQueryStatement.appendParameter
train
private void appendParameter(Object value, StringBuffer buf) { if (value instanceof Query) { appendSubQuery((Query) value, buf); } else { buf.append("?"); } }
java
{ "resource": "" }
q9177
SqlQueryStatement.appendSubQuery
train
private void appendSubQuery(Query subQuery, StringBuffer buf) { buf.append(" ("); buf.append(getSubQuerySQL(subQuery)); buf.append(") "); }
java
{ "resource": "" }
q9178
SqlQueryStatement.getSubQuerySQL
train
private String getSubQuerySQL(Query subQuery) { ClassDescriptor cld = getRoot().cld.getRepository().getDescriptorFor(subQuery.getSearchClass()); String sql; if (subQuery instanceof QueryBySQL) { sql = ((QueryBySQL) subQuery).getSql(); } else { sql = new SqlSelectStatement(this, m_platform, cld, subQuery, m_logger).getStatement(); } return sql; }
java
{ "resource": "" }
q9179
SqlQueryStatement.addJoin
train
private void addJoin(TableAlias left, Object[] leftKeys, TableAlias right, Object[] rightKeys, boolean outer, String name) { TableAlias extAlias, rightCopy; left.addJoin(new Join(left, leftKeys, right, rightKeys, outer, name)); // build join between left and extents of right if (right.hasExtents()) { for (int i = 0; i < right.extents.size(); i++) { extAlias = (TableAlias) right.extents.get(i); FieldDescriptor[] extKeys = getExtentFieldDescriptors(extAlias, (FieldDescriptor[]) rightKeys); left.addJoin(new Join(left, leftKeys, extAlias, extKeys, true, name)); } } // we need to copy the alias on the right for each extent on the left if (left.hasExtents()) { for (int i = 0; i < left.extents.size(); i++) { extAlias = (TableAlias) left.extents.get(i); FieldDescriptor[] extKeys = getExtentFieldDescriptors(extAlias, (FieldDescriptor[]) leftKeys); rightCopy = right.copy("C" + i); // copies are treated like normal extents right.extents.add(rightCopy); right.extents.addAll(rightCopy.extents); addJoin(extAlias, extKeys, rightCopy, rightKeys, true, name); } } }
java
{ "resource": "" }
q9180
SqlQueryStatement.getExtentFieldDescriptors
train
private FieldDescriptor[] getExtentFieldDescriptors(TableAlias extAlias, FieldDescriptor[] fds) { FieldDescriptor[] result = new FieldDescriptor[fds.length]; for (int i = 0; i < fds.length; i++) { result[i] = extAlias.cld.getFieldDescriptorByName(fds[i].getAttributeName()); } return result; }
java
{ "resource": "" }
q9181
SqlQueryStatement.createTableAlias
train
private TableAlias createTableAlias(String aTable, String aPath, String aUserAlias) { if (aUserAlias == null) { return createTableAlias(aTable, aPath); } else { return createTableAlias(aTable, aUserAlias + ALIAS_SEPARATOR + aPath); } }
java
{ "resource": "" }
q9182
SqlQueryStatement.getTableAliasForPath
train
private TableAlias getTableAliasForPath(String aPath, List hintClasses) { return (TableAlias) m_pathToAlias.get(buildAliasKey(aPath, hintClasses)); }
java
{ "resource": "" }
q9183
SqlQueryStatement.setTableAliasForPath
train
private void setTableAliasForPath(String aPath, List hintClasses, TableAlias anAlias) { m_pathToAlias.put(buildAliasKey(aPath, hintClasses), anAlias); }
java
{ "resource": "" }
q9184
SqlQueryStatement.buildAliasKey
train
private String buildAliasKey(String aPath, List hintClasses) { if (hintClasses == null || hintClasses.isEmpty()) { return aPath; } StringBuffer buf = new StringBuffer(aPath); for (Iterator iter = hintClasses.iterator(); iter.hasNext();) { Class hint = (Class) iter.next(); buf.append(" "); buf.append(hint.getName()); } return buf.toString(); }
java
{ "resource": "" }
q9185
SqlQueryStatement.setTableAliasForClassDescriptor
train
private void setTableAliasForClassDescriptor(ClassDescriptor aCld, TableAlias anAlias) { if (m_cldToAlias.get(aCld) == null) { m_cldToAlias.put(aCld, anAlias); } }
java
{ "resource": "" }
q9186
SqlQueryStatement.getTableAliasForPath
train
private TableAlias getTableAliasForPath(String aPath, String aUserAlias, List hintClasses) { if (aUserAlias == null) { return getTableAliasForPath(aPath, hintClasses); } else { return getTableAliasForPath(aUserAlias + ALIAS_SEPARATOR + aPath, hintClasses); } }
java
{ "resource": "" }
q9187
SqlQueryStatement.appendGroupByClause
train
protected void appendGroupByClause(List groupByFields, StringBuffer buf) { if (groupByFields == null || groupByFields.size() == 0) { return; } buf.append(" GROUP BY "); for (int i = 0; i < groupByFields.size(); i++) { FieldHelper cf = (FieldHelper) groupByFields.get(i); if (i > 0) { buf.append(","); } appendColName(cf.name, false, null, buf); } }
java
{ "resource": "" }
q9188
SqlQueryStatement.appendTableWithJoins
train
protected void appendTableWithJoins(TableAlias alias, StringBuffer where, StringBuffer buf) { int stmtFromPos = 0; byte joinSyntax = getJoinSyntaxType(); if (joinSyntax == SQL92_JOIN_SYNTAX) { stmtFromPos = buf.length(); // store position of join (by: Terry Dexter) } if (alias == getRoot()) { // BRJ: also add indirection table to FROM-clause for MtoNQuery if (getQuery() instanceof MtoNQuery) { MtoNQuery mnQuery = (MtoNQuery)m_query; buf.append(getTableAliasForPath(mnQuery.getIndirectionTable(), null).getTableAndAlias()); buf.append(", "); } buf.append(alias.getTableAndAlias()); } else if (joinSyntax != SQL92_NOPAREN_JOIN_SYNTAX) { buf.append(alias.getTableAndAlias()); } if (!alias.hasJoins()) { return; } for (Iterator it = alias.iterateJoins(); it.hasNext();) { Join join = (Join) it.next(); if (joinSyntax == SQL92_JOIN_SYNTAX) { appendJoinSQL92(join, where, buf); if (it.hasNext()) { buf.insert(stmtFromPos, "("); buf.append(")"); } } else if (joinSyntax == SQL92_NOPAREN_JOIN_SYNTAX) { appendJoinSQL92NoParen(join, where, buf); } else { appendJoin(where, buf, join); } } }
java
{ "resource": "" }
q9189
SqlQueryStatement.appendJoin
train
private void appendJoin(StringBuffer where, StringBuffer buf, Join join) { buf.append(","); appendTableWithJoins(join.right, where, buf); if (where.length() > 0) { where.append(" AND "); } join.appendJoinEqualities(where); }
java
{ "resource": "" }
q9190
SqlQueryStatement.appendJoinSQL92
train
private void appendJoinSQL92(Join join, StringBuffer where, StringBuffer buf) { if (join.isOuter) { buf.append(" LEFT OUTER JOIN "); } else { buf.append(" INNER JOIN "); } if (join.right.hasJoins()) { buf.append("("); appendTableWithJoins(join.right, where, buf); buf.append(")"); } else { appendTableWithJoins(join.right, where, buf); } buf.append(" ON "); join.appendJoinEqualities(buf); }
java
{ "resource": "" }
q9191
SqlQueryStatement.appendJoinSQL92NoParen
train
private void appendJoinSQL92NoParen(Join join, StringBuffer where, StringBuffer buf) { if (join.isOuter) { buf.append(" LEFT OUTER JOIN "); } else { buf.append(" INNER JOIN "); } buf.append(join.right.getTableAndAlias()); buf.append(" ON "); join.appendJoinEqualities(buf); appendTableWithJoins(join.right, where, buf); }
java
{ "resource": "" }
q9192
SqlQueryStatement.buildJoinTree
train
private void buildJoinTree(Criteria crit) { Enumeration e = crit.getElements(); while (e.hasMoreElements()) { Object o = e.nextElement(); if (o instanceof Criteria) { buildJoinTree((Criteria) o); } else { SelectionCriteria c = (SelectionCriteria) o; // BRJ skip SqlCriteria if (c instanceof SqlCriteria) { continue; } // BRJ: Outer join for OR boolean useOuterJoin = (crit.getType() == Criteria.OR); // BRJ: do not build join tree for subQuery attribute if (c.getAttribute() != null && c.getAttribute() instanceof String) { //buildJoinTreeForColumn((String) c.getAttribute(), useOuterJoin, c.getAlias(), c.getPathClasses()); buildJoinTreeForColumn((String) c.getAttribute(), useOuterJoin, c.getUserAlias(), c.getPathClasses()); } if (c instanceof FieldCriteria) { FieldCriteria cc = (FieldCriteria) c; buildJoinTreeForColumn((String) cc.getValue(), useOuterJoin, c.getUserAlias(), c.getPathClasses()); } } } }
java
{ "resource": "" }
q9193
SqlQueryStatement.buildSuperJoinTree
train
protected void buildSuperJoinTree(TableAlias left, ClassDescriptor cld, String name, boolean useOuterJoin) { ClassDescriptor superCld = cld.getSuperClassDescriptor(); if (superCld != null) { SuperReferenceDescriptor superRef = cld.getSuperReference(); FieldDescriptor[] leftFields = superRef.getForeignKeyFieldDescriptors(cld); TableAlias base_alias = getTableAliasForPath(name, null, null); String aliasName = String.valueOf(getAliasChar()) + m_aliasCount++; TableAlias right = new TableAlias(superCld, aliasName, useOuterJoin, null); Join join1to1 = new Join(left, leftFields, right, superCld.getPkFields(), useOuterJoin, "superClass"); base_alias.addJoin(join1to1); buildSuperJoinTree(right, superCld, name, useOuterJoin); } }
java
{ "resource": "" }
q9194
SqlQueryStatement.buildMultiJoinTree
train
private void buildMultiJoinTree(TableAlias left, ClassDescriptor cld, String name, boolean useOuterJoin) { DescriptorRepository repository = cld.getRepository(); Class[] multiJoinedClasses = repository.getSubClassesMultipleJoinedTables(cld, false); for (int i = 0; i < multiJoinedClasses.length; i++) { ClassDescriptor subCld = repository.getDescriptorFor(multiJoinedClasses[i]); SuperReferenceDescriptor srd = subCld.getSuperReference(); if (srd != null) { FieldDescriptor[] leftFields = subCld.getPkFields(); FieldDescriptor[] rightFields = srd.getForeignKeyFieldDescriptors(subCld); TableAlias base_alias = getTableAliasForPath(name, null, null); String aliasName = String.valueOf(getAliasChar()) + m_aliasCount++; TableAlias right = new TableAlias(subCld, aliasName, false, null); Join join1to1 = new Join(left, leftFields, right, rightFields, useOuterJoin, "subClass"); base_alias.addJoin(join1to1); buildMultiJoinTree(right, subCld, name, useOuterJoin); } } }
java
{ "resource": "" }
q9195
SqlQueryStatement.splitCriteria
train
protected void splitCriteria() { Criteria whereCrit = getQuery().getCriteria(); Criteria havingCrit = getQuery().getHavingCriteria(); if (whereCrit == null || whereCrit.isEmpty()) { getJoinTreeToCriteria().put(getRoot(), null); } else { // TODO: parameters list shold be modified when the form is reduced to DNF. getJoinTreeToCriteria().put(getRoot(), whereCrit); buildJoinTree(whereCrit); } if (havingCrit != null && !havingCrit.isEmpty()) { buildJoinTree(havingCrit); } }
java
{ "resource": "" }
q9196
PrepareReportingCommand.getFilter
train
private Filter getFilter(String layerFilter, String[] featureIds) throws GeomajasException { Filter filter = null; if (null != layerFilter) { filter = filterService.parseFilter(layerFilter); } if (null != featureIds) { Filter fidFilter = filterService.createFidFilter(featureIds); if (null == filter) { filter = fidFilter; } else { filter = filterService.createAndFilter(filter, fidFilter); } } return filter; }
java
{ "resource": "" }
q9197
TileMapUrlBuilder.resolveProxyUrl
train
public static String resolveProxyUrl(String relativeUrl, TileMap tileMap, String baseTmsUrl) { TileCode tc = parseTileCode(relativeUrl); return buildUrl(tc, tileMap, baseTmsUrl); }
java
{ "resource": "" }
q9198
GraphsHandler.getModuleGraph
train
public AbstractGraph getModuleGraph(final String moduleId) { final ModuleHandler moduleHandler = new ModuleHandler(repoHandler); final DbModule module = moduleHandler.getModule(moduleId); final DbOrganization organization = moduleHandler.getOrganization(module); filters.setCorporateFilter(new CorporateFilter(organization)); final AbstractGraph graph = new ModuleGraph(); addModuleToGraph(module, graph, 0); return graph; }
java
{ "resource": "" }
q9199
GraphsHandler.addModuleToGraph
train
private void addModuleToGraph(final DbModule module, final AbstractGraph graph, final int depth) { if (graph.isTreated(graph.getId(module))) { return; } final String moduleElementId = graph.getId(module); graph.addElement(moduleElementId, module.getVersion(), depth == 0); if (filters.getDepthHandler().shouldGoDeeper(depth)) { for (final DbDependency dep : DataUtils.getAllDbDependencies(module)) { if(filters.shouldBeInReport(dep)){ addDependencyToGraph(dep, graph, depth + 1, moduleElementId); } } } }
java
{ "resource": "" }