idx
int64
0
41.2k
question
stringlengths
74
4.04k
target
stringlengths
7
750
900
public ObjectReferenceDescriptor getObjectReferenceDescriptorByName ( String name ) { ObjectReferenceDescriptor ord = ( ObjectReferenceDescriptor ) getObjectReferenceDescriptorsNameMap ( ) . get ( name ) ; if ( ord == null ) { ClassDescriptor superCld = getSuperClassDescriptor ( ) ; if ( superCld != null ) { ord = superCld . getObjectReferenceDescriptorByName ( name ) ; } } return ord ; }
Get an ObjectReferenceDescriptor by name BRJ
901
public CollectionDescriptor getCollectionDescriptorByName ( String name ) { if ( name == null ) { return null ; } CollectionDescriptor cod = ( CollectionDescriptor ) getCollectionDescriptorNameMap ( ) . get ( name ) ; if ( cod == null ) { ClassDescriptor superCld = getSuperClassDescriptor ( ) ; if ( superCld != null ) { cod = superCld . getCollectionDescriptorByName ( name ) ; } } return cod ; }
Get an CollectionDescriptor by name BRJ
902
public ClassDescriptor getSuperClassDescriptor ( ) { if ( ! m_superCldSet ) { if ( getBaseClass ( ) != null ) { m_superCld = getRepository ( ) . getDescriptorFor ( getBaseClass ( ) ) ; if ( m_superCld . isAbstract ( ) || m_superCld . isInterface ( ) ) { throw new MetadataException ( "Super class mapping only work for real class, but declared super class" + " is an interface or is abstract. Declared class: " + m_superCld . getClassNameOfObject ( ) ) ; } } m_superCldSet = true ; } return m_superCld ; }
Answers the ClassDescriptor referenced by super ReferenceDescriptor .
903
public void addExtentClass ( String newExtentClassName ) { extentClassNames . add ( newExtentClassName ) ; if ( m_repository != null ) m_repository . addExtent ( newExtentClassName , this ) ; }
add an Extent class to the current descriptor
904
public void setProxyClass ( Class newProxyClass ) { proxyClass = newProxyClass ; if ( proxyClass == null ) { setProxyClassName ( null ) ; } else { proxyClassName = proxyClass . getName ( ) ; } }
Sets the proxy class to be used .
905
public FieldDescriptor getAutoIncrementField ( ) { if ( m_autoIncrementField == null ) { FieldDescriptor [ ] fds = getPkFields ( ) ; for ( int i = 0 ; i < fds . length ; i ++ ) { FieldDescriptor fd = fds [ i ] ; if ( fd . isAutoIncrement ( ) ) { m_autoIncrementField = fd ; break ; } } } if ( m_autoIncrementField == null ) { LoggerFactory . getDefaultLogger ( ) . warn ( this . getClass ( ) . getName ( ) + ": " + "Could not find autoincrement attribute for class: " + this . getClassNameOfObject ( ) ) ; } return m_autoIncrementField ; }
Returns the first found autoincrement field defined in this class descriptor . Use carefully when multiple autoincrement field were defined .
906
public ValueContainer [ ] getCurrentLockingValues ( Object o ) throws PersistenceBrokerException { FieldDescriptor [ ] fields = getLockingFields ( ) ; ValueContainer [ ] result = new ValueContainer [ fields . length ] ; for ( int i = 0 ; i < result . length ; i ++ ) { result [ i ] = new ValueContainer ( fields [ i ] . getPersistentField ( ) . get ( o ) , fields [ i ] . getJdbcType ( ) ) ; } return result ; }
returns an Array with an Objects CURRENT locking VALUES BRJ
907
public void updateLockingValues ( Object obj ) throws PersistenceBrokerException { FieldDescriptor [ ] fields = getLockingFields ( ) ; for ( int i = 0 ; i < fields . length ; i ++ ) { FieldDescriptor fmd = fields [ i ] ; if ( fmd . isUpdateLock ( ) ) { PersistentField f = fmd . getPersistentField ( ) ; Object cv = f . get ( obj ) ; if ( ( f . getType ( ) == int . class ) || ( f . getType ( ) == Integer . class ) ) { int newCv = 0 ; if ( cv != null ) { newCv = ( ( Number ) cv ) . intValue ( ) ; } newCv ++ ; f . set ( obj , new Integer ( newCv ) ) ; } else if ( ( f . getType ( ) == long . class ) || ( f . getType ( ) == Long . class ) ) { long newCv = 0 ; if ( cv != null ) { newCv = ( ( Number ) cv ) . longValue ( ) ; } newCv ++ ; f . set ( obj , new Long ( newCv ) ) ; } else if ( f . getType ( ) == Timestamp . class ) { long newCv = System . currentTimeMillis ( ) ; f . set ( obj , new Timestamp ( newCv ) ) ; } } } }
updates the values for locking fields BRJ handles int long Timestamp respects updateLock so locking field are only updated when updateLock is true
908
public Constructor getZeroArgumentConstructor ( ) { if ( zeroArgumentConstructor == null && ! alreadyLookedupZeroArguments ) { try { zeroArgumentConstructor = getClassOfObject ( ) . getConstructor ( NO_PARAMS ) ; } catch ( NoSuchMethodException e ) { try { zeroArgumentConstructor = getClassOfObject ( ) . getDeclaredConstructor ( NO_PARAMS ) ; zeroArgumentConstructor . setAccessible ( true ) ; } catch ( NoSuchMethodException e2 ) { LoggerFactory . getDefaultLogger ( ) . warn ( this . getClass ( ) . getName ( ) + ": " + "No zero argument constructor defined for " + this . getClassOfObject ( ) ) ; } } alreadyLookedupZeroArguments = true ; } return zeroArgumentConstructor ; }
returns the zero argument constructor for the class represented by this class descriptor or null if a zero argument constructor does not exist . If the zero argument constructor for this class is not public it is made accessible before being returned .
909
private synchronized void setInitializationMethod ( Method newMethod ) { if ( newMethod != null ) { if ( newMethod . getParameterTypes ( ) . length > 0 ) { throw new MetadataException ( "Initialization methods must be zero argument methods: " + newMethod . getClass ( ) . getName ( ) + "." + newMethod . getName ( ) ) ; } if ( ! newMethod . isAccessible ( ) ) { newMethod . setAccessible ( true ) ; } } this . initializationMethod = newMethod ; }
sets the initialization method for this descriptor
910
private synchronized void setFactoryMethod ( Method newMethod ) { if ( newMethod != null ) { if ( newMethod . getParameterTypes ( ) . length > 0 ) { throw new MetadataException ( "Factory methods must be zero argument methods: " + newMethod . getClass ( ) . getName ( ) + "." + newMethod . getName ( ) ) ; } if ( ! newMethod . isAccessible ( ) ) { newMethod . setAccessible ( true ) ; } } this . factoryMethod = newMethod ; }
Specify the method to instantiate objects represented by this descriptor .
911
protected org . apache . log4j . helpers . PatternParser createPatternParser ( final String pattern ) { return new FoundationLoggingPatternParser ( pattern ) ; }
Returns PatternParser used to parse the conversion string . Subclasses may override this to return a subclass of PatternParser which recognize custom conversion characters .
912
public String format ( final LoggingEvent event ) { final StringBuffer buf = new StringBuffer ( ) ; for ( PatternConverter c = head ; c != null ; c = c . next ) { c . format ( buf , event ) ; } return buf . toString ( ) ; }
Formats a logging event to a writer .
913
protected String getUniqueString ( FieldDescriptor field ) throws SequenceManagerException { ResultSetAndStatement rsStmt = null ; String returnValue = null ; try { rsStmt = getBrokerForClass ( ) . serviceJdbcAccess ( ) . executeSQL ( "select newid()" , field . getClassDescriptor ( ) , Query . NOT_SCROLLABLE ) ; if ( rsStmt . m_rs . next ( ) ) { returnValue = rsStmt . m_rs . getString ( 1 ) ; } else { LoggerFactory . getDefaultLogger ( ) . error ( this . getClass ( ) + ": Can't lookup new oid for field " + field ) ; } } catch ( PersistenceBrokerException e ) { throw new SequenceManagerException ( e ) ; } catch ( SQLException e ) { throw new SequenceManagerException ( e ) ; } finally { if ( rsStmt != null ) rsStmt . close ( ) ; } return returnValue ; }
returns a unique String for given field . the returned uid is unique accross all tables .
914
public static Object getObjectFromColumn ( ResultSet rs , Integer jdbcType , int columnId ) throws SQLException { return getObjectFromColumn ( rs , null , jdbcType , null , columnId ) ; }
Returns an java object read from the specified ResultSet column .
915
public Object getTransferData ( DataFlavor flavor ) throws UnsupportedFlavorException , java . io . IOException { if ( flavor . isMimeTypeEqual ( OJBMETADATA_FLAVOR ) ) return selectedDescriptors ; else throw new UnsupportedFlavorException ( flavor ) ; }
Returns an object which represents the data to be transferred . The class of the object returned is defined by the representation class of the flavor .
916
protected void load ( ) { String fn = System . getProperty ( OJB_PROPERTIES_FILE , OJB_PROPERTIES_FILE ) ; setFilename ( fn ) ; super . load ( ) ; repositoryFilename = getString ( "repositoryFile" , OJB_METADATA_FILE ) ; objectCacheClass = getClass ( "ObjectCacheClass" , ObjectCacheDefaultImpl . class , ObjectCache . class ) ; persistentFieldClass = getClass ( "PersistentFieldClass" , PersistentFieldDirectImpl . class , PersistentField . class ) ; persistenceBrokerClass = getClass ( "PersistenceBrokerClass" , PersistenceBrokerImpl . class , PersistenceBroker . class ) ; listProxyClass = getClass ( "ListProxyClass" , ListProxyDefaultImpl . class ) ; setProxyClass = getClass ( "SetProxyClass" , SetProxyDefaultImpl . class ) ; collectionProxyClass = getClass ( "CollectionProxyClass" , CollectionProxyDefaultImpl . class ) ; indirectionHandlerClass = getClass ( "IndirectionHandlerClass" , IndirectionHandlerJDKImpl . class , IndirectionHandler . class ) ; proxyFactoryClass = getClass ( "ProxyFactoryClass" , ProxyFactoryJDKImpl . class , ProxyFactory . class ) ; useImplicitLocking = getBoolean ( "ImplicitLocking" , false ) ; lockAssociationAsWrites = ( getString ( "LockAssociations" , "WRITE" ) . equalsIgnoreCase ( "WRITE" ) ) ; oqlCollectionClass = getClass ( "OqlCollectionClass" , DListImpl . class , ManageableCollection . class ) ; sqlInLimit = getInteger ( "SqlInLimit" , - 1 ) ; maxActive = getInteger ( PoolConfiguration . MAX_ACTIVE , PoolConfiguration . DEFAULT_MAX_ACTIVE ) ; maxIdle = getInteger ( PoolConfiguration . MAX_IDLE , PoolConfiguration . DEFAULT_MAX_IDLE ) ; maxWait = getLong ( PoolConfiguration . MAX_WAIT , PoolConfiguration . DEFAULT_MAX_WAIT ) ; timeBetweenEvictionRunsMillis = getLong ( PoolConfiguration . TIME_BETWEEN_EVICTION_RUNS_MILLIS , PoolConfiguration . DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS ) ; minEvictableIdleTimeMillis = getLong ( PoolConfiguration . MIN_EVICTABLE_IDLE_TIME_MILLIS , PoolConfiguration . DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS ) ; whenExhaustedAction = getByte ( PoolConfiguration . WHEN_EXHAUSTED_ACTION , PoolConfiguration . DEFAULT_WHEN_EXHAUSTED_ACTION ) ; useSerializedRepository = getBoolean ( "useSerializedRepository" , false ) ; }
Loads the configuration from file OBJ . properties . If the system property OJB . properties is set then the configuration in that file is loaded . Otherwise the file OJB . properties is tried . If that is also unsuccessful then the configuration is filled with default values .
917
public Collection getReaders ( Object obj ) { Collection result = null ; try { Identity oid = new Identity ( obj , getBroker ( ) ) ; byte selector = ( byte ) 'r' ; byte [ ] requestBarr = buildRequestArray ( oid , selector ) ; HttpURLConnection conn = getHttpUrlConnection ( ) ; BufferedOutputStream out = new BufferedOutputStream ( conn . getOutputStream ( ) ) ; out . write ( requestBarr , 0 , requestBarr . length ) ; out . flush ( ) ; InputStream in = conn . getInputStream ( ) ; ObjectInputStream ois = new ObjectInputStream ( in ) ; result = ( Collection ) ois . readObject ( ) ; ois . close ( ) ; out . close ( ) ; conn . disconnect ( ) ; } catch ( Throwable t ) { throw new PersistenceBrokerException ( t ) ; } return result ; }
returns a collection of Reader LockEntries for object obj . If now LockEntries could be found an empty Vector is returned .
918
public void addColumnPair ( String localColumn , String remoteColumn ) { if ( ! _localColumns . contains ( localColumn ) ) { _localColumns . add ( localColumn ) ; } if ( ! _remoteColumns . contains ( remoteColumn ) ) { _remoteColumns . add ( remoteColumn ) ; } }
Adds a column pair to this foreignkey .
919
public int compare ( Object objA , Object objB ) { String idAStr = _table . getColumn ( ( String ) objA ) . getProperty ( "id" ) ; String idBStr = _table . getColumn ( ( String ) objB ) . getProperty ( "id" ) ; int idA ; int idB ; try { idA = Integer . parseInt ( idAStr ) ; } catch ( Exception ex ) { return 1 ; } try { idB = Integer . parseInt ( idBStr ) ; } catch ( Exception ex ) { return - 1 ; } return idA < idB ? - 1 : ( idA > idB ? 1 : 0 ) ; }
Compares two columns given by their names .
920
public String getAlias ( String path ) { if ( m_allPathsAliased && m_attributePath . lastIndexOf ( path ) != - 1 ) { return m_name ; } Object retObj = m_mapping . get ( path ) ; if ( retObj != null ) { return ( String ) retObj ; } return null ; }
Returns the name of this alias if path has been added to the aliased portions of attributePath
921
public void addClass ( ClassDescriptorDef classDef ) { classDef . setOwner ( this ) ; _classDefs . put ( classDef . getQualifiedName ( ) , classDef ) ; }
Adds the class descriptor to this model .
922
public void checkConstraints ( String checkLevel ) throws ConstraintException { for ( Iterator it = getClasses ( ) ; it . hasNext ( ) ; ) { ( ( ClassDescriptorDef ) it . next ( ) ) . checkConstraints ( checkLevel ) ; } new ModelConstraints ( ) . check ( this , checkLevel ) ; }
Checks constraints on this model .
923
public FinishRequest toFinishRequest ( boolean includeHeaders ) { if ( includeHeaders ) { return new FinishRequest ( body , copyHeaders ( headers ) , statusCode ) ; } else { String mime = null ; if ( body != null ) { mime = "text/plain" ; if ( headers != null && ( headers . containsKey ( "Content-Type" ) || headers . containsKey ( "content-type" ) ) ) { mime = headers . get ( "Content-Type" ) ; if ( mime == null ) { mime = headers . get ( "content-type" ) ; } } } return new FinishRequest ( body , mime , statusCode ) ; } }
Convert the message to a FinishRequest
924
public void setAttributeEditable ( Attribute attribute , boolean editable ) { attribute . setEditable ( editable ) ; if ( ! ( attribute instanceof LazyAttribute ) ) { if ( attribute instanceof ManyToOneAttribute ) { setAttributeEditable ( ( ( ManyToOneAttribute ) attribute ) . getValue ( ) , editable ) ; } else if ( attribute instanceof OneToManyAttribute ) { List < AssociationValue > values = ( ( OneToManyAttribute ) attribute ) . getValue ( ) ; for ( AssociationValue value : values ) { setAttributeEditable ( value , editable ) ; } } } }
Set editable state on an attribute . This needs to also set the state on the associated attributes .
925
private void increaseBeliefCount ( String bName ) { Object belief = this . getBelief ( bName ) ; int count = 0 ; if ( belief != null ) { count = ( Integer ) belief ; } this . setBelief ( bName , count + 1 ) ; }
If the belief its a count of some sort his counting its increased by one .
926
private void setBelief ( String bName , Object value ) { introspector . setBeliefValue ( this . getLocalName ( ) , bName , value , null ) ; }
Modifies the belief referenced by bName parameter .
927
public static Organization createOrganization ( final String name ) { final Organization organization = new Organization ( ) ; organization . setName ( name ) ; return organization ; }
Generates an organization regarding the parameters .
928
public static Module createModule ( final String name , final String version ) { final Module module = new Module ( ) ; module . setName ( name ) ; module . setVersion ( version ) ; module . setPromoted ( false ) ; return module ; }
Generates a module regarding the parameters .
929
public static Artifact createArtifact ( final String groupId , final String artifactId , final String version , final String classifier , final String type , final String extension , final String origin ) { final Artifact artifact = new Artifact ( ) ; artifact . setGroupId ( groupId ) ; artifact . setArtifactId ( artifactId ) ; artifact . setVersion ( version ) ; if ( classifier != null ) { artifact . setClassifier ( classifier ) ; } if ( type != null ) { artifact . setType ( type ) ; } if ( extension != null ) { artifact . setExtension ( extension ) ; } artifact . setOrigin ( origin == null ? "maven" : origin ) ; return artifact ; }
Generates an artifact regarding the parameters .
930
public static License createLicense ( final String name , final String longName , final String comments , final String regexp , final String url ) { final License license = new License ( ) ; license . setName ( name ) ; license . setLongName ( longName ) ; license . setComments ( comments ) ; license . setRegexp ( regexp ) ; license . setUrl ( url ) ; return license ; }
Generates a License regarding the parameters .
931
public static Comment createComment ( final String entityId , final String entityType , final String action , final String commentedText , final String user , final Date date ) { final Comment comment = new Comment ( ) ; comment . setEntityId ( entityId ) ; comment . setEntityType ( entityType ) ; comment . setAction ( action ) ; comment . setCommentText ( commentedText ) ; comment . setCommentedBy ( user ) ; comment . setCreatedDateTime ( date ) ; return comment ; }
Generates a comment regarding the parameters .
932
private void writeAllEnvelopes ( boolean reuse ) { performM2NUnlinkEntries ( ) ; Iterator iter ; iter = ( ( List ) mvOrderOfIds . clone ( ) ) . iterator ( ) ; while ( iter . hasNext ( ) ) { ObjectEnvelope mod = ( ObjectEnvelope ) mhtObjectEnvelopes . get ( iter . next ( ) ) ; boolean insert = false ; if ( needsCommit ) { insert = mod . needsInsert ( ) ; mod . getModificationState ( ) . commit ( mod ) ; if ( reuse && insert ) { getTransaction ( ) . doSingleLock ( mod . getClassDescriptor ( ) , mod . getObject ( ) , mod . getIdentity ( ) , Transaction . WRITE ) ; } } mod . cleanup ( reuse , insert ) ; } performM2NLinkEntries ( ) ; }
commit all envelopes against the current broker
933
private void checkAllEnvelopes ( PersistenceBroker broker ) { Iterator iter = ( ( List ) mvOrderOfIds . clone ( ) ) . iterator ( ) ; while ( iter . hasNext ( ) ) { ObjectEnvelope mod = ( ObjectEnvelope ) mhtObjectEnvelopes . get ( iter . next ( ) ) ; if ( ! mod . getModificationState ( ) . isTransient ( ) ) { mod . markReferenceElements ( broker ) ; } } }
Mark objects no longer available in collection for delete and new objects for insert .
934
public void rollback ( ) { try { Iterator iter = mvOrderOfIds . iterator ( ) ; while ( iter . hasNext ( ) ) { ObjectEnvelope mod = ( ObjectEnvelope ) mhtObjectEnvelopes . get ( iter . next ( ) ) ; if ( log . isDebugEnabled ( ) ) log . debug ( "rollback: " + mod ) ; if ( mod . hasChanged ( transaction . getBroker ( ) ) ) { mod . setModificationState ( mod . getModificationState ( ) . markDirty ( ) ) ; } mod . getModificationState ( ) . rollback ( mod ) ; } } finally { needsCommit = false ; } afterWriteCleanup ( ) ; }
perform rollback on all tx - states
935
public void remove ( Object pKey ) { Identity id ; if ( pKey instanceof Identity ) { id = ( Identity ) pKey ; } else { id = transaction . getBroker ( ) . serviceIdentity ( ) . buildIdentity ( pKey ) ; } mhtObjectEnvelopes . remove ( id ) ; mvOrderOfIds . remove ( id ) ; }
remove an objects entry from the object registry
936
private void reorder ( ) { if ( getTransaction ( ) . isOrdering ( ) && needsCommit && mhtObjectEnvelopes . size ( ) > 1 ) { ObjectEnvelopeOrdering ordering = new ObjectEnvelopeOrdering ( mvOrderOfIds , mhtObjectEnvelopes ) ; ordering . reorder ( ) ; Identity [ ] newOrder = ordering . getOrdering ( ) ; mvOrderOfIds . clear ( ) ; for ( int i = 0 ; i < newOrder . length ; i ++ ) { mvOrderOfIds . add ( newOrder [ i ] ) ; } } }
Reorder the objects in the table to resolve referential integrity dependencies .
937
private void cascadeMarkedForInsert ( ) { List alreadyPrepared = new ArrayList ( ) ; for ( int i = 0 ; i < markedForInsertList . size ( ) ; i ++ ) { ObjectEnvelope mod = ( ObjectEnvelope ) markedForInsertList . get ( i ) ; if ( mod . needsInsert ( ) ) { cascadeInsertFor ( mod , alreadyPrepared ) ; alreadyPrepared . clear ( ) ; } } markedForInsertList . clear ( ) ; }
Starts recursive insert on all insert objects object graph
938
private void cascadeInsertFor ( ObjectEnvelope mod , List alreadyPrepared ) { if ( alreadyPrepared . contains ( mod . getIdentity ( ) ) ) return ; alreadyPrepared . add ( mod . getIdentity ( ) ) ; ClassDescriptor cld = getTransaction ( ) . getBroker ( ) . getClassDescriptor ( mod . getObject ( ) . getClass ( ) ) ; List refs = cld . getObjectReferenceDescriptors ( true ) ; cascadeInsertSingleReferences ( mod , refs , alreadyPrepared ) ; List colls = cld . getCollectionDescriptors ( true ) ; cascadeInsertCollectionReferences ( mod , colls , alreadyPrepared ) ; }
Walk through the object graph of the specified insert object . Was used for recursive object graph walk .
939
private void cascadeMarkedForDeletion ( ) { List alreadyPrepared = new ArrayList ( ) ; for ( int i = 0 ; i < markedForDeletionList . size ( ) ; i ++ ) { ObjectEnvelope mod = ( ObjectEnvelope ) markedForDeletionList . get ( i ) ; if ( ! isNewAssociatedObject ( mod . getIdentity ( ) ) ) { cascadeDeleteFor ( mod , alreadyPrepared ) ; alreadyPrepared . clear ( ) ; } } markedForDeletionList . clear ( ) ; }
Starts recursive delete on all delete objects object graph
940
private void cascadeDeleteFor ( ObjectEnvelope mod , List alreadyPrepared ) { if ( alreadyPrepared . contains ( mod . getIdentity ( ) ) ) return ; alreadyPrepared . add ( mod . getIdentity ( ) ) ; ClassDescriptor cld = getTransaction ( ) . getBroker ( ) . getClassDescriptor ( mod . getObject ( ) . getClass ( ) ) ; List refs = cld . getObjectReferenceDescriptors ( true ) ; cascadeDeleteSingleReferences ( mod , refs , alreadyPrepared ) ; List colls = cld . getCollectionDescriptors ( true ) ; cascadeDeleteCollectionReferences ( mod , colls , alreadyPrepared ) ; }
Walk through the object graph of the specified delete object . Was used for recursive object graph walk .
941
public ManageableCollection getCollectionByQuery ( Class collectionClass , Query query , boolean lazy ) throws PersistenceBrokerException { ManageableCollection result ; try { if ( query == null ) { result = ( ManageableCollection ) collectionClass . newInstance ( ) ; } else { if ( lazy ) { result = pb . getProxyFactory ( ) . createCollectionProxy ( pb . getPBKey ( ) , query , collectionClass ) ; } else { result = getCollectionByQuery ( collectionClass , query . getSearchClass ( ) , query ) ; } } return result ; } catch ( Exception e ) { if ( e instanceof PersistenceBrokerException ) { throw ( PersistenceBrokerException ) e ; } else { throw new PersistenceBrokerException ( e ) ; } } }
retrieve a collection of type collectionClass matching the Query query if lazy = true return a CollectionProxy
942
public void retrieveReferences ( Object newObj , ClassDescriptor cld , boolean forced ) throws PersistenceBrokerException { Iterator i = cld . getObjectReferenceDescriptors ( ) . iterator ( ) ; final Class saveClassToPrefetch = classToPrefetch ; classToPrefetch = null ; pb . getInternalCache ( ) . enableMaterializationCache ( ) ; try { while ( i . hasNext ( ) ) { ObjectReferenceDescriptor rds = ( ObjectReferenceDescriptor ) i . next ( ) ; retrieveReference ( newObj , cld , rds , forced ) ; } pb . getInternalCache ( ) . disableMaterializationCache ( ) ; } catch ( RuntimeException e ) { pb . getInternalCache ( ) . doLocalClear ( ) ; throw e ; } finally { classToPrefetch = saveClassToPrefetch ; } }
Retrieve all References
943
private boolean hasNullifiedFK ( FieldDescriptor [ ] fkFieldDescriptors , Object [ ] fkValues ) { boolean result = true ; for ( int i = 0 ; i < fkValues . length ; i ++ ) { if ( ! pb . serviceBrokerHelper ( ) . representsNull ( fkFieldDescriptors [ i ] , fkValues [ i ] ) ) { result = false ; break ; } } return result ; }
to avoid creation of unmaterializable proxies
944
private Query getFKQuery ( Object obj , ClassDescriptor cld , CollectionDescriptor cds ) { Query fkQuery ; QueryByCriteria fkQueryCrit ; if ( cds . isMtoNRelation ( ) ) { fkQueryCrit = getFKQueryMtoN ( obj , cld , cds ) ; } else { fkQueryCrit = getFKQuery1toN ( obj , cld , cds ) ; } if ( ! cds . getOrderBy ( ) . isEmpty ( ) ) { Iterator iter = cds . getOrderBy ( ) . iterator ( ) ; while ( iter . hasNext ( ) ) { fkQueryCrit . addOrderBy ( ( FieldHelper ) iter . next ( ) ) ; } } if ( cds . getQueryCustomizer ( ) != null ) { fkQuery = cds . getQueryCustomizer ( ) . customizeQuery ( obj , pb , cds , fkQueryCrit ) ; } else { fkQuery = fkQueryCrit ; } return fkQuery ; }
Answer the foreign key query to retrieve the collection defined by CollectionDescriptor
945
public Query getPKQuery ( Identity oid ) { Object [ ] values = oid . getPrimaryKeyValues ( ) ; ClassDescriptor cld = pb . getClassDescriptor ( oid . getObjectsTopLevelClass ( ) ) ; FieldDescriptor [ ] fields = cld . getPkFields ( ) ; Criteria criteria = new Criteria ( ) ; for ( int i = 0 ; i < fields . length ; i ++ ) { FieldDescriptor fld = fields [ i ] ; criteria . addEqualTo ( fld . getAttributeName ( ) , values [ i ] ) ; } return QueryFactory . newQuery ( cld . getClassOfObject ( ) , criteria ) ; }
Answer the primary key query to retrieve an Object
946
public void retrieveCollections ( Object newObj , ClassDescriptor cld , boolean forced ) throws PersistenceBrokerException { doRetrieveCollections ( newObj , cld , forced , false ) ; }
Retrieve all Collection attributes of a given instance
947
public void retrieveProxyCollections ( Object newObj , ClassDescriptor cld , boolean forced ) throws PersistenceBrokerException { doRetrieveCollections ( newObj , cld , forced , true ) ; }
Retrieve all Collection attributes of a given instance and make all of the Proxy Collections
948
public void removePrefetchingListeners ( ) { if ( prefetchingListeners != null ) { for ( Iterator it = prefetchingListeners . iterator ( ) ; it . hasNext ( ) ; ) { PBPrefetchingListener listener = ( PBPrefetchingListener ) it . next ( ) ; listener . removeThisListener ( ) ; } prefetchingListeners . clear ( ) ; } }
remove all prefetching listeners
949
protected void init ( ) throws IOException { if ( null != configurationFile ) { log . debug ( "Get base configuration from {}" , configurationFile ) ; manager = new DefaultCacheManager ( configurationFile ) ; } else { GlobalConfigurationBuilder builder = new GlobalConfigurationBuilder ( ) ; builder . globalJmxStatistics ( ) . allowDuplicateDomains ( true ) ; manager = new DefaultCacheManager ( builder . build ( ) ) ; } if ( listener == null ) { listener = new InfinispanCacheListener ( ) ; } manager . addListener ( listener ) ; Map < String , Map < CacheCategory , CacheService > > cacheCache = new HashMap < String , Map < CacheCategory , CacheService > > ( ) ; if ( null != defaultConfiguration ) { setCaches ( cacheCache , null , defaultConfiguration ) ; } for ( Layer layer : layerMap . values ( ) ) { CacheInfo ci = configurationService . getLayerExtraInfo ( layer . getLayerInfo ( ) , CacheInfo . class ) ; if ( null != ci ) { setCaches ( cacheCache , layer , ci ) ; } } }
Finish initializing service .
950
protected static String ConvertBinaryOperator ( int oper ) { String oper_string ; switch ( oper ) { default : case EQUAL : oper_string = "=" ; break ; case LIKE : oper_string = "LIKE" ; break ; case NOT_EQUAL : oper_string = "!=" ; break ; case LESS_THAN : oper_string = "<" ; break ; case GREATER_THAN : oper_string = ">" ; break ; case GREATER_EQUAL : oper_string = ">=" ; break ; case LESS_EQUAL : oper_string = "<=" ; break ; } return oper_string ; }
Static method to convert a binary operator into a string .
951
public void writeObject ( Object o , GraphicsDocument document , boolean asChild ) throws RenderException { document . writeElement ( "vml:shape" , asChild ) ; Point p = ( Point ) o ; String adj = document . getFormatter ( ) . format ( p . getX ( ) ) + "," + document . getFormatter ( ) . format ( p . getY ( ) ) ; document . writeAttribute ( "adj" , adj ) ; }
Writes the object to the specified document optionally creating a child element . The object in this case should be a point .
952
public void setStatusBarMessage ( final String message ) { Object [ ] listeners = listenerList . getListenerList ( ) ; for ( int i = listeners . length - 2 ; i >= 0 ; i -= 2 ) { if ( listeners [ i ] == StatusMessageListener . class ) { ( ( StatusMessageListener ) listeners [ i + 1 ] ) . statusMessageReceived ( message ) ; } } }
Set a status message in the JTextComponent passed to this model .
953
public void reportSqlError ( String message , java . sql . SQLException sqlEx ) { StringBuffer strBufMessages = new StringBuffer ( ) ; java . sql . SQLException currentSqlEx = sqlEx ; do { strBufMessages . append ( "\n" + sqlEx . getErrorCode ( ) + ":" + sqlEx . getMessage ( ) ) ; currentSqlEx = currentSqlEx . getNextException ( ) ; } while ( currentSqlEx != null ) ; System . err . println ( message + strBufMessages . toString ( ) ) ; sqlEx . printStackTrace ( ) ; }
Method for reporting SQLException . This is used by the treenodes if retrieving information for a node is not successful .
954
public Object copy ( final Object obj , final PersistenceBroker broker ) { return clone ( obj , IdentityMapFactory . getIdentityMap ( ) , broker ) ; }
Uses an IdentityMap to make sure we don t recurse infinitely on the same object in a cyclic object model . Proxies
955
protected Object getObjectFromResultSet ( ) throws PersistenceBrokerException { try { return super . getObjectFromResultSet ( ) ; } catch ( PersistenceBrokerException e ) { Identity oid = getIdentityFromResultSet ( ) ; return getBroker ( ) . getObjectByIdentity ( oid ) ; } }
returns a proxy or a fully materialized Object from the current row of the underlying resultset .
956
public void createInsertionSql ( Database model , Platform platform , Writer writer ) throws IOException { for ( Iterator it = _beans . iterator ( ) ; it . hasNext ( ) ; ) { writer . write ( platform . getInsertSql ( model , ( DynaBean ) it . next ( ) ) ) ; if ( it . hasNext ( ) ) { writer . write ( "\n" ) ; } } }
Generates and writes the sql for inserting the currently contained data objects .
957
public void insert ( Platform platform , Database model , int batchSize ) throws SQLException { if ( batchSize <= 1 ) { for ( Iterator it = _beans . iterator ( ) ; it . hasNext ( ) ; ) { platform . insert ( model , ( DynaBean ) it . next ( ) ) ; } } else { for ( int startIdx = 0 ; startIdx < _beans . size ( ) ; startIdx += batchSize ) { platform . insert ( model , _beans . subList ( startIdx , startIdx + batchSize ) ) ; } } }
Inserts the currently contained data objects into the database .
958
private InputStream connect ( String url ) throws IOException { URLConnection conn = new URL ( URL_BASE + url ) . openConnection ( ) ; conn . setConnectTimeout ( CONNECT_TIMEOUT ) ; conn . setReadTimeout ( READ_TIMEOUT ) ; conn . setRequestProperty ( "User-Agent" , USER_AGENT ) ; return conn . getInputStream ( ) ; }
Open the connection to the server .
959
public synchronized void abortTransaction ( ) throws TransactionNotInProgressException { if ( isInTransaction ( ) ) { fireBrokerEvent ( BEFORE_ROLLBACK_EVENT ) ; setInTransaction ( false ) ; clearRegistrationLists ( ) ; referencesBroker . removePrefetchingListeners ( ) ; if ( connectionManager . isInLocalTransaction ( ) ) this . connectionManager . localRollback ( ) ; fireBrokerEvent ( AFTER_ROLLBACK_EVENT ) ; } }
Abort and close the transaction . Calling abort abandons all persistent object modifications and releases the associated locks . If transaction is not in progress a TransactionNotInProgressException is thrown
960
public void delete ( Object obj , boolean ignoreReferences ) throws PersistenceBrokerException { if ( isTxCheck ( ) && ! isInTransaction ( ) ) { if ( logger . isEnabledFor ( Logger . ERROR ) ) { String msg = "No running PB-tx found. Please, only delete objects in context of a PB-transaction" + " to avoid side-effects - e.g. when rollback of complex objects." ; try { throw new Exception ( "** Delete object without active PersistenceBroker transaction **" ) ; } catch ( Exception e ) { logger . error ( msg , e ) ; } } } try { doDelete ( obj , ignoreReferences ) ; } finally { markedForDelete . clear ( ) ; } }
Deletes the concrete representation of the specified object in the underlying persistence system . This method is intended for use in top - level api or by internal calls .
961
private void doDelete ( Object obj , boolean ignoreReferences ) throws PersistenceBrokerException { if ( obj != null ) { obj = getProxyFactory ( ) . getRealObject ( obj ) ; if ( obj == null ) return ; if ( markedForDelete . contains ( obj ) ) { return ; } ClassDescriptor cld = getClassDescriptor ( obj . getClass ( ) ) ; if ( ! serviceBrokerHelper ( ) . assertValidPkForDelete ( cld , obj ) ) { String msg = "Cannot delete object without valid PKs. " + obj ; logger . error ( msg ) ; return ; } markedForDelete . add ( obj ) ; Identity oid = serviceIdentity ( ) . buildIdentity ( cld , obj ) ; BEFORE_DELETE_EVENT . setTarget ( obj ) ; fireBrokerEvent ( BEFORE_DELETE_EVENT ) ; BEFORE_DELETE_EVENT . setTarget ( null ) ; performDeletion ( cld , obj , oid , ignoreReferences ) ; AFTER_DELETE_EVENT . setTarget ( obj ) ; fireBrokerEvent ( AFTER_DELETE_EVENT ) ; AFTER_DELETE_EVENT . setTarget ( null ) ; connectionManager . executeBatchIfNecessary ( ) ; } }
do delete given object . Should be used by all intern classes to delete objects .
962
private void deleteByQuery ( Query query , ClassDescriptor cld ) throws PersistenceBrokerException { if ( logger . isDebugEnabled ( ) ) { logger . debug ( "deleteByQuery " + cld . getClassNameOfObject ( ) + ", " + query ) ; } if ( query instanceof QueryBySQL ) { String sql = ( ( QueryBySQL ) query ) . getSql ( ) ; this . dbAccess . executeUpdateSQL ( sql , cld ) ; } else { if ( query instanceof QueryByIdentity ) { QueryByIdentity qbi = ( QueryByIdentity ) query ; Object oid = qbi . getExampleObject ( ) ; if ( ! ( oid instanceof Identity ) ) { oid = serviceIdentity ( ) . buildIdentity ( oid ) ; } query = referencesBroker . getPKQuery ( ( Identity ) oid ) ; } if ( ! cld . isInterface ( ) ) { this . dbAccess . executeDelete ( query , cld ) ; } String lastUsedTable = cld . getFullTableName ( ) ; if ( cld . isExtent ( ) ) { Iterator extents = getDescriptorRepository ( ) . getAllConcreteSubclassDescriptors ( cld ) . iterator ( ) ; while ( extents . hasNext ( ) ) { ClassDescriptor extCld = ( ClassDescriptor ) extents . next ( ) ; if ( ! extCld . getFullTableName ( ) . equals ( lastUsedTable ) ) { lastUsedTable = extCld . getFullTableName ( ) ; this . dbAccess . executeDelete ( query , extCld ) ; } } } } }
Extent aware Delete by Query
963
public void store ( Object obj ) throws PersistenceBrokerException { obj = extractObjectToStore ( obj ) ; if ( obj == null ) return ; ClassDescriptor cld = getClassDescriptor ( obj . getClass ( ) ) ; boolean insert = serviceBrokerHelper ( ) . hasNullPKField ( cld , obj ) ; Identity oid = serviceIdentity ( ) . buildIdentity ( cld , obj ) ; if ( ! insert ) { insert = objectCache . lookup ( oid ) == null && ! serviceBrokerHelper ( ) . doesExist ( cld , oid , obj ) ; } store ( obj , oid , cld , insert ) ; }
Store an Object .
964
protected void store ( Object obj , Identity oid , ClassDescriptor cld , boolean insert ) { store ( obj , oid , cld , insert , false ) ; }
Internal used method which start the real store work .
965
public void link ( Object targetObject , ClassDescriptor cld , ObjectReferenceDescriptor rds , Object referencedObject , boolean insert ) { if ( referencedObject == null ) { if ( ! insert ) { unlinkFK ( targetObject , cld , rds ) ; } } else { setFKField ( targetObject , cld , rds , referencedObject ) ; } }
Assign FK value to target object by reading PK values of referenced object .
966
public void unlinkFK ( Object targetObject , ClassDescriptor cld , ObjectReferenceDescriptor rds ) { setFKField ( targetObject , cld , rds , null ) ; }
Unkink FK fields of target object .
967
public void linkOneToOne ( Object obj , ClassDescriptor cld , ObjectReferenceDescriptor rds , boolean insert ) { storeAndLinkOneToOne ( true , obj , cld , rds , true ) ; }
Assign FK value of main object with PK values of the reference object .
968
public void linkOneToMany ( Object obj , CollectionDescriptor cod , boolean insert ) { Object referencedObjects = cod . getPersistentField ( ) . get ( obj ) ; storeAndLinkOneToMany ( true , obj , cod , referencedObjects , insert ) ; }
Assign FK value to all n - side objects referenced by given object .
969
public void linkMtoN ( Object obj , CollectionDescriptor cod , boolean insert ) { Object referencedObjects = cod . getPersistentField ( ) . get ( obj ) ; storeAndLinkMtoN ( true , obj , cod , referencedObjects , insert ) ; }
Assign FK values and store entries in indirection table for all objects referenced by given object .
970
public void retrieveReference ( Object pInstance , String pAttributeName ) throws PersistenceBrokerException { if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Retrieving reference named [" + pAttributeName + "] on object of type [" + pInstance . getClass ( ) . getName ( ) + "]" ) ; } ClassDescriptor cld = getClassDescriptor ( pInstance . getClass ( ) ) ; CollectionDescriptor cod = cld . getCollectionDescriptorByName ( pAttributeName ) ; getInternalCache ( ) . enableMaterializationCache ( ) ; Identity oid = serviceIdentity ( ) . buildIdentity ( pInstance ) ; boolean needLocalRemove = false ; if ( getInternalCache ( ) . doLocalLookup ( oid ) == null ) { getInternalCache ( ) . doInternalCache ( oid , pInstance , MaterializationCache . TYPE_TEMP ) ; needLocalRemove = true ; } try { if ( cod != null ) { referencesBroker . retrieveCollection ( pInstance , cld , cod , true ) ; } else { ObjectReferenceDescriptor ord = cld . getObjectReferenceDescriptorByName ( pAttributeName ) ; if ( ord != null ) { referencesBroker . retrieveReference ( pInstance , cld , ord , true ) ; } else { throw new PersistenceBrokerException ( "did not find attribute " + pAttributeName + " for class " + pInstance . getClass ( ) . getName ( ) ) ; } } if ( needLocalRemove ) getInternalCache ( ) . doLocalRemove ( oid ) ; getInternalCache ( ) . disableMaterializationCache ( ) ; } catch ( RuntimeException e ) { getInternalCache ( ) . doLocalClear ( ) ; throw e ; } }
retrieve a single reference - or collection attribute of a persistent instance .
971
public ManageableCollection getCollectionByQuery ( Class collectionClass , Query query ) throws PersistenceBrokerException { return referencesBroker . getCollectionByQuery ( collectionClass , query , false ) ; }
retrieve a collection of type collectionClass matching the Query query
972
protected OJBIterator getIteratorFromQuery ( Query query , ClassDescriptor cld ) throws PersistenceBrokerException { RsIteratorFactory factory = RsIteratorFactoryImpl . getInstance ( ) ; OJBIterator result = getRsIteratorFromQuery ( query , cld , factory ) ; if ( query . usePaging ( ) ) { result = new PagingIterator ( result , query . getStartAtIndex ( ) , query . getEndAtIndex ( ) ) ; } return result ; }
Get an extent aware Iterator based on the Query
973
public Object doGetObjectByIdentity ( Identity id ) throws PersistenceBrokerException { if ( logger . isDebugEnabled ( ) ) logger . debug ( "getObjectByIdentity " + id ) ; Object obj = objectCache . lookup ( id ) ; if ( obj == null ) { obj = getDBObject ( id ) ; } else { ClassDescriptor cld = getClassDescriptor ( obj . getClass ( ) ) ; if ( cld . isAlwaysRefresh ( ) ) { refreshInstance ( obj , id , cld ) ; } checkRefreshRelationships ( obj , id , cld ) ; } AFTER_LOOKUP_EVENT . setTarget ( obj ) ; fireBrokerEvent ( AFTER_LOOKUP_EVENT ) ; AFTER_LOOKUP_EVENT . setTarget ( null ) ; return obj ; }
Internal used method to retrieve object based on Identity .
974
private void refreshInstance ( Object cachedInstance , Identity oid , ClassDescriptor cld ) { Object freshInstance = getPlainDBObject ( cld , oid ) ; FieldDescriptor [ ] fields = cld . getFieldDescriptions ( ) ; FieldDescriptor fmd ; PersistentField fld ; for ( int i = 0 ; i < fields . length ; i ++ ) { fmd = fields [ i ] ; fld = fmd . getPersistentField ( ) ; fld . set ( cachedInstance , fld . get ( freshInstance ) ) ; } }
refresh all primitive typed attributes of a cached instance with the current values from the database . refreshing of reference and collection attributes is not done here .
975
public Object getObjectByQuery ( Query query ) throws PersistenceBrokerException { Object result = null ; if ( query instanceof QueryByIdentity ) { Object obj = query . getExampleObject ( ) ; if ( obj instanceof Identity ) { Identity oid = ( Identity ) obj ; result = getObjectByIdentity ( oid ) ; } else { if ( ! serviceBrokerHelper ( ) . hasNullPKField ( getClassDescriptor ( obj . getClass ( ) ) , obj ) ) { Identity oid = serviceIdentity ( ) . buildIdentity ( obj ) ; result = getObjectByIdentity ( oid ) ; } } } else { Class itemClass = query . getSearchClass ( ) ; ClassDescriptor cld = getClassDescriptor ( itemClass ) ; OJBIterator it = getIteratorFromQuery ( query , cld ) ; try { while ( result == null && it . hasNext ( ) ) { result = it . next ( ) ; } } finally { if ( it != null ) it . releaseDbResources ( ) ; } } return result ; }
retrieve an Object by query I . e perform a SELECT ... FROM ... WHERE ... in an RDBMS
976
public Enumeration getPKEnumerationByQuery ( Class primaryKeyClass , Query query ) throws PersistenceBrokerException { if ( logger . isDebugEnabled ( ) ) logger . debug ( "getPKEnumerationByQuery " + query ) ; query . setFetchSize ( 1 ) ; ClassDescriptor cld = getClassDescriptor ( query . getSearchClass ( ) ) ; return new PkEnumeration ( query , cld , primaryKeyClass , this ) ; }
returns an Enumeration of PrimaryKey Objects for objects of class DataClass . The Elements returned come from a SELECT ... WHERE Statement that is defined by the fields and their coresponding values of listFields and listValues . Useful for EJB Finder Methods ...
977
public void store ( Object obj , ObjectModification mod ) throws PersistenceBrokerException { obj = extractObjectToStore ( obj ) ; if ( obj == null ) { return ; } ClassDescriptor cld = getClassDescriptor ( obj . getClass ( ) ) ; Identity oid = serviceIdentity ( ) . buildIdentity ( cld , obj ) ; if ( mod . needsInsert ( ) ) { store ( obj , oid , cld , true ) ; } else if ( mod . needsUpdate ( ) ) { store ( obj , oid , cld , false ) ; } else { storeCollections ( obj , cld , mod . needsInsert ( ) ) ; } }
Makes object obj persistent in the underlying persistence system . E . G . by INSERT INTO ... or UPDATE ... in an RDBMS . The ObjectModification parameter can be used to determine whether INSERT or update is to be used . This functionality is typically called from transaction managers that track which objects have to be stored . If the object is an unmaterialized proxy the method return immediately .
978
private void storeToDb ( Object obj , ClassDescriptor cld , Identity oid , boolean insert , boolean ignoreReferences ) { storeReferences ( obj , cld , insert , ignoreReferences ) ; Object [ ] pkValues = oid . getPrimaryKeyValues ( ) ; if ( ! serviceBrokerHelper ( ) . assertValidPksForStore ( cld . getPkFields ( ) , pkValues ) ) { pkValues = serviceBrokerHelper ( ) . getKeyValues ( cld , obj ) ; if ( ! serviceBrokerHelper ( ) . assertValidPksForStore ( cld . getPkFields ( ) , pkValues ) ) { String append = insert ? " on insert" : " on update" ; throw new PersistenceBrokerException ( "assertValidPkFields failed for Object of type: " + cld . getClassNameOfObject ( ) + append ) ; } } if ( cld . getSuperClass ( ) != null ) { ClassDescriptor superCld = getDescriptorRepository ( ) . getDescriptorFor ( cld . getSuperClass ( ) ) ; storeToDb ( obj , superCld , oid , insert ) ; } if ( insert ) { dbAccess . executeInsert ( cld , obj ) ; if ( oid . isTransient ( ) ) { oid = serviceIdentity ( ) . buildIdentity ( cld , obj ) ; } } else { try { dbAccess . executeUpdate ( cld , obj ) ; } catch ( OptimisticLockException e ) { objectCache . remove ( oid ) ; throw e ; } } objectCache . doInternalCache ( oid , obj , ObjectCacheInternal . TYPE_WRITE ) ; if ( ! ignoreReferences ) storeCollections ( obj , cld , insert ) ; }
I pulled this out of internal store so that when doing multiple table inheritance i can recurse this function .
979
public Iterator getReportQueryIteratorByQuery ( Query query ) throws PersistenceBrokerException { ClassDescriptor cld = getClassDescriptor ( query . getSearchClass ( ) ) ; return getReportQueryIteratorFromQuery ( query , cld ) ; }
Get an Iterator based on the ReportQuery
980
private OJBIterator getRsIteratorFromQuery ( Query query , ClassDescriptor cld , RsIteratorFactory factory ) throws PersistenceBrokerException { query . setFetchSize ( 1 ) ; if ( query instanceof QueryBySQL ) { if ( logger . isDebugEnabled ( ) ) logger . debug ( "Creating SQL-RsIterator for class [" + cld . getClassNameOfObject ( ) + "]" ) ; return factory . createRsIterator ( ( QueryBySQL ) query , cld , this ) ; } if ( ! cld . isExtent ( ) || ! query . getWithExtents ( ) ) { if ( logger . isDebugEnabled ( ) ) logger . debug ( "Creating RsIterator for class [" + cld . getClassNameOfObject ( ) + "]" ) ; return factory . createRsIterator ( query , cld , this ) ; } if ( logger . isDebugEnabled ( ) ) logger . debug ( "Creating ChainingIterator for class [" + cld . getClassNameOfObject ( ) + "]" ) ; ChainingIterator chainingIter = new ChainingIterator ( ) ; if ( ! cld . isInterface ( ) ) { if ( logger . isDebugEnabled ( ) ) logger . debug ( "Adding RsIterator for class [" + cld . getClassNameOfObject ( ) + "] to ChainingIterator" ) ; chainingIter . addIterator ( factory . createRsIterator ( query , cld , this ) ) ; } Iterator extents = getDescriptorRepository ( ) . getAllConcreteSubclassDescriptors ( cld ) . iterator ( ) ; while ( extents . hasNext ( ) ) { ClassDescriptor extCld = ( ClassDescriptor ) extents . next ( ) ; if ( chainingIter . containsIteratorForTable ( extCld . getFullTableName ( ) ) ) { if ( logger . isDebugEnabled ( ) ) logger . debug ( "Skipping class [" + extCld . getClassNameOfObject ( ) + "]" ) ; } else { if ( logger . isDebugEnabled ( ) ) logger . debug ( "Adding RsIterator of class [" + extCld . getClassNameOfObject ( ) + "] to ChainingIterator" ) ; chainingIter . addIterator ( factory . createRsIterator ( query , extCld , this ) ) ; } } return chainingIter ; }
Get an extent aware RsIterator based on the Query
981
private OJBIterator getReportQueryIteratorFromQuery ( Query query , ClassDescriptor cld ) throws PersistenceBrokerException { RsIteratorFactory factory = ReportRsIteratorFactoryImpl . getInstance ( ) ; OJBIterator result = getRsIteratorFromQuery ( query , cld , factory ) ; if ( query . usePaging ( ) ) { result = new PagingIterator ( result , query . getStartAtIndex ( ) , query . getEndAtIndex ( ) ) ; } return result ; }
Get an extent aware Iterator based on the ReportQuery
982
public static String getModuleName ( final String moduleId ) { final int splitter = moduleId . indexOf ( ':' ) ; if ( splitter == - 1 ) { return moduleId ; } return moduleId . substring ( 0 , splitter ) ; }
Split a module Id to get the module name
983
public static String getModuleVersion ( final String moduleId ) { final int splitter = moduleId . lastIndexOf ( ':' ) ; if ( splitter == - 1 ) { return moduleId ; } return moduleId . substring ( splitter + 1 ) ; }
Split a module Id to get the module version
984
public static String getGroupId ( final String gavc ) { final int splitter = gavc . indexOf ( ':' ) ; if ( splitter == - 1 ) { return gavc ; } return gavc . substring ( 0 , splitter ) ; }
Split an artifact gavc to get the groupId
985
public static List < DbModule > getAllSubmodules ( final DbModule module ) { final List < DbModule > submodules = new ArrayList < DbModule > ( ) ; submodules . addAll ( module . getSubmodules ( ) ) ; for ( final DbModule submodule : module . getSubmodules ( ) ) { submodules . addAll ( getAllSubmodules ( submodule ) ) ; } return submodules ; }
Return the list of all the module submodules
986
public void init ( final MultivaluedMap < String , String > queryParameters ) { final String scopeCompileParam = queryParameters . getFirst ( ServerAPI . SCOPE_COMPILE_PARAM ) ; if ( scopeCompileParam != null ) { this . scopeComp = Boolean . valueOf ( scopeCompileParam ) ; } final String scopeProvidedParam = queryParameters . getFirst ( ServerAPI . SCOPE_PROVIDED_PARAM ) ; if ( scopeProvidedParam != null ) { this . scopePro = Boolean . valueOf ( scopeProvidedParam ) ; } final String scopeRuntimeParam = queryParameters . getFirst ( ServerAPI . SCOPE_RUNTIME_PARAM ) ; if ( scopeRuntimeParam != null ) { this . scopeRun = Boolean . valueOf ( scopeRuntimeParam ) ; } final String scopeTestParam = queryParameters . getFirst ( ServerAPI . SCOPE_TEST_PARAM ) ; if ( scopeTestParam != null ) { this . scopeTest = Boolean . valueOf ( scopeTestParam ) ; } }
The parameter must never be null
987
private PersistenceBroker obtainBroker ( ) { PersistenceBroker _broker ; try { if ( pbKey == null ) { log . warn ( "No tx runnning and PBKey is null, try to use the default PB" ) ; _broker = PersistenceBrokerFactory . defaultPersistenceBroker ( ) ; } else { _broker = PersistenceBrokerFactory . createPersistenceBroker ( pbKey ) ; } } catch ( PBFactoryException e ) { log . error ( "Could not obtain PB for PBKey " + pbKey , e ) ; throw new OJBRuntimeException ( "Unexpected micro-kernel exception" , e ) ; } return _broker ; }
Used to get PB when no tx is running .
988
private void addSequence ( String sequenceName , HighLowSequence seq ) { String jcdAlias = getBrokerForClass ( ) . serviceConnectionManager ( ) . getConnectionDescriptor ( ) . getJcdAlias ( ) ; Map mapForDB = ( Map ) sequencesDBMap . get ( jcdAlias ) ; if ( mapForDB == null ) { mapForDB = new HashMap ( ) ; } mapForDB . put ( sequenceName , seq ) ; sequencesDBMap . put ( jcdAlias , mapForDB ) ; }
Put new sequence object for given sequence name .
989
protected void removeSequence ( String sequenceName ) { Map mapForDB = ( Map ) sequencesDBMap . get ( getBrokerForClass ( ) . serviceConnectionManager ( ) . getConnectionDescriptor ( ) . getJcdAlias ( ) ) ; if ( mapForDB != null ) { synchronized ( SequenceManagerHighLowImpl . class ) { mapForDB . remove ( sequenceName ) ; } } }
Remove the sequence for given sequence name .
990
public PBKey getPBKey ( ) { if ( pbKey == null ) { this . pbKey = new PBKey ( this . getJcdAlias ( ) , this . getUserName ( ) , this . getPassWord ( ) ) ; } return pbKey ; }
Return a key to identify the connection descriptor .
991
public void setJdbcLevel ( String jdbcLevel ) { if ( jdbcLevel != null ) { try { double intLevel = Double . parseDouble ( jdbcLevel ) ; setJdbcLevel ( intLevel ) ; } catch ( NumberFormatException nfe ) { setJdbcLevel ( 2.0 ) ; logger . info ( "Specified JDBC level was not numeric (Value=" + jdbcLevel + "), used default jdbc level of 2.0 " ) ; } } else { setJdbcLevel ( 2.0 ) ; logger . info ( "Specified JDBC level was null, used default jdbc level of 2.0 " ) ; } }
Sets the jdbcLevel . parse the string setting and check that it is indeed an integer .
992
public synchronized boolean checkWrite ( TransactionImpl tx , Object obj ) { if ( log . isDebugEnabled ( ) ) log . debug ( "LM.checkWrite(tx-" + tx . getGUID ( ) + ", " + new Identity ( obj , tx . getBroker ( ) ) . toString ( ) + ")" ) ; LockStrategy lockStrategy = LockStrategyFactory . getStrategyFor ( obj ) ; return lockStrategy . checkWrite ( tx , obj ) ; }
checks if there is a writelock for transaction tx on object obj . Returns true if so else false .
993
public void checkpoint ( ObjectEnvelope mod ) throws org . apache . ojb . broker . PersistenceBrokerException { mod . doDelete ( ) ; mod . setModificationState ( StateTransient . getInstance ( ) ) ; }
rollback the transaction
994
public void checkpoint ( ObjectEnvelope mod ) throws PersistenceBrokerException { mod . doInsert ( ) ; mod . setModificationState ( StateOldClean . getInstance ( ) ) ; }
checkpoint the ObjectModification
995
public List < String > getModuleVersions ( final String name , final FiltersHolder filters ) { final List < String > versions = repositoryHandler . getModuleVersions ( name , filters ) ; if ( versions . isEmpty ( ) ) { throw new WebApplicationException ( Response . status ( Response . Status . NOT_FOUND ) . entity ( "Module " + name + " does not exist." ) . build ( ) ) ; } return versions ; }
Returns the available module names regarding the filters
996
public DbModule getModule ( final String moduleId ) { final DbModule dbModule = repositoryHandler . getModule ( moduleId ) ; if ( dbModule == null ) { throw new WebApplicationException ( Response . status ( Response . Status . NOT_FOUND ) . entity ( "Module " + moduleId + " does not exist." ) . build ( ) ) ; } return dbModule ; }
Returns a module
997
public void deleteModule ( final String moduleId ) { final DbModule module = getModule ( moduleId ) ; repositoryHandler . deleteModule ( module . getId ( ) ) ; for ( final String gavc : DataUtils . getAllArtifacts ( module ) ) { repositoryHandler . deleteArtifact ( gavc ) ; } }
Delete a module
998
public List < DbLicense > getModuleLicenses ( final String moduleId , final LicenseMatcher licenseMatcher ) { final DbModule module = getModule ( moduleId ) ; final List < DbLicense > licenses = new ArrayList < > ( ) ; final FiltersHolder filters = new FiltersHolder ( ) ; final ArtifactHandler artifactHandler = new ArtifactHandler ( repositoryHandler , licenseMatcher ) ; for ( final String gavc : DataUtils . getAllArtifacts ( module ) ) { licenses . addAll ( artifactHandler . getArtifactLicenses ( gavc , filters ) ) ; } return licenses ; }
Return a licenses view of the targeted module
999
public void promoteModule ( final String moduleId ) { final DbModule module = getModule ( moduleId ) ; for ( final String gavc : DataUtils . getAllArtifacts ( module ) ) { final DbArtifact artifact = repositoryHandler . getArtifact ( gavc ) ; artifact . setPromoted ( true ) ; repositoryHandler . store ( artifact ) ; } repositoryHandler . promoteModule ( module ) ; }
Perform the module promotion