idx
int64
0
41.2k
question
stringlengths
73
5.81k
target
stringlengths
5
918
35,900
private Map < String , Object > buildResultMap ( SearchResponse response , KunderaQuery query , EntityMetadata m , MetamodelImpl metaModel ) { Map < String , Object > map = new LinkedHashMap < > ( ) ; ESResponseWrapper esResponseReader = new ESResponseWrapper ( ) ; for ( SearchHit hit : response . getHits ( ) ) { Objec...
Builds the result map .
35,901
private SearchResponse getSearchResponse ( KunderaQuery kunderaQuery , FilteredQueryBuilder queryBuilder , QueryBuilder filter , ESQuery query , EntityMetadata m , int firstResult , int maxResults , KunderaMetadata kunderaMetadata ) { SearchRequestBuilder builder = client . prepareSearch ( m . getSchema ( ) . toLowerCa...
Gets the search response .
35,902
private void persistBlocksAndTransactions ( EthBlock block ) { Block blk = EtherObjectConverterUtil . convertEtherBlockToKunderaBlock ( block , false ) ; try { em . persist ( blk ) ; LOGGER . debug ( "Block number " + getBlockNumberWithRawData ( blk . getNumber ( ) ) + " is stored!" ) ; } catch ( Exception ex ) { LOGGE...
Persist blocks and transactions .
35,903
private void persistTransactions ( Transaction tx , String blockNumber ) { LOGGER . debug ( "Going to save transactions for Block - " + getBlockNumberWithRawData ( blockNumber ) + "!" ) ; try { em . persist ( tx ) ; LOGGER . debug ( "Transaction with hash " + tx . getHash ( ) + " is stored!" ) ; } catch ( Exception ex ...
Persist transactions .
35,904
public EthBlock getFirstBlock ( boolean includeTransactions ) { try { return web3j . ethGetBlockByNumber ( DefaultBlockParameterName . EARLIEST , includeTransactions ) . send ( ) ; } catch ( IOException ex ) { LOGGER . error ( "Not able to find the EARLIEST block. " , ex ) ; throw new KunderaException ( "Not able to fi...
Gets the first block .
35,905
public void saveBlocks ( BigInteger startBlockNumber , BigInteger endBlockNumber ) { if ( endBlockNumber . compareTo ( startBlockNumber ) < 1 ) { LOGGER . error ( "startBlockNumber must be smaller than endBlockNumer" ) ; throw new KunderaException ( "startBlockNumber must be smaller than endBlockNumer" ) ; } if ( start...
Gets the blocks .
35,906
private void initializeWeb3j ( PropertyReader reader ) { String endPoint = reader . getProperty ( EthConstants . ETHEREUM_NODE_ENDPOINT ) ; if ( endPoint == null || endPoint . isEmpty ( ) ) { LOGGER . error ( "Specify - " + EthConstants . ETHEREUM_NODE_ENDPOINT + " in " + EthConstants . KUNDERA_ETHEREUM_PROPERTIES ) ; ...
Initialize web3j .
35,907
private void initializeKunderaParams ( PropertyReader reader ) { Map < String , String > props = KunderaPropertyBuilder . populatePersistenceUnitProperties ( reader ) ; try { emf = Persistence . createEntityManagerFactory ( EthConstants . PU , props ) ; } catch ( ClientResolverException ex ) { LOGGER . error ( "Not abl...
Initialize kundera params .
35,908
public static synchronized EntityManager getEM ( EntityManagerFactory emf , final String propertiesPath , final String clazzName ) { Map < ? , Map < String , String > > clientProperties = new HashMap < > ( ) ; Map < String , Map < String , String > > entityConfigurations = Collections . synchronizedMap ( new HashMap < ...
Gets the em .
35,909
private static void loadClientProperties ( String propertiesPath , String clazzName , Map < ? , Map < String , String > > clientProperties , Map < String , Map < String , String > > entityConfigurations ) { InputStream inputStream = PropertyReader . class . getClassLoader ( ) . getResourceAsStream ( propertiesPath ) ; ...
Load client properties .
35,910
protected Object createPoolOrConnection ( ) { if ( log . isInfoEnabled ( ) ) log . info ( "Initializing Neo4J database connection..." ) ; PersistenceUnitMetadata puMetadata = kunderaMetadata . getApplicationMetadata ( ) . getPersistenceUnitMetadata ( getPersistenceUnit ( ) ) ; Properties props = puMetadata . getPropert...
Create Neo4J Embedded Graph DB instance that acts as a Neo4J connection repository for Neo4J If a Neo4j specfic client properties file is specified in persistence . xml it initializes DB instance with those properties . Other DB instance is initialized with default properties .
35,911
public final void persist ( Object e ) { checkClosed ( ) ; checkTransactionNeeded ( ) ; try { getPersistenceDelegator ( ) . persist ( e ) ; } catch ( Exception ex ) { doRollback ( ) ; throw new KunderaException ( ex ) ; } }
Make an instance managed and persistent .
35,912
public final < E > E merge ( E e ) { checkClosed ( ) ; checkTransactionNeeded ( ) ; try { return getPersistenceDelegator ( ) . merge ( e ) ; } catch ( Exception ex ) { doRollback ( ) ; throw new KunderaException ( ex ) ; } }
Merge the state of the given entity into the current persistence context .
35,913
public final < E > E find ( Class < E > entityClass , Object primaryKey ) { checkClosed ( ) ; checkTransactionNeeded ( ) ; return getPersistenceDelegator ( ) . findById ( entityClass , primaryKey ) ; }
Find by primary key . Search for an entity of the specified class and primary key . If the entity instance is contained in the persistence context it is returned from there .
35,914
public < T > T find ( Class < T > entityClass , Object primaryKey , Map < String , Object > properties ) { checkClosed ( ) ; checkTransactionNeeded ( ) ; Map < String , Object > currentProperties = getProperties ( ) ; getPersistenceDelegator ( ) . populateClientProperties ( properties ) ; T result = find ( entityClass ...
Find by primary key using the specified properties . Search for an entity of the specified class and primary key . If the entity instance is contained in the persistence context it is returned from there . If a vendor - specific property or hint is not recognized it is silently ignored .
35,915
public void refresh ( Object entity , Map < String , Object > properties ) { checkClosed ( ) ; Map < String , Object > currentProperties = getProperties ( ) ; getPersistenceDelegator ( ) . populateClientProperties ( properties ) ; refresh ( entity ) ; getPersistenceDelegator ( ) . populateClientProperties ( currentProp...
Refresh the state of the instance from the database using the specified properties and overwriting changes made to the entity if any . If a vendor - specific property or hint is not recognized it is silently ignored .
35,916
public void setProperty ( String paramString , Object paramObject ) { checkClosed ( ) ; if ( getProperties ( ) == null ) { this . properties = new HashMap < String , Object > ( ) ; } this . properties . put ( paramString , paramObject ) ; getPersistenceDelegator ( ) . populateClientProperties ( this . properties ) ; }
Set an entity manager property or hint . If a vendor - specific property or hint is not recognized it is silently ignored .
35,917
public static Properties getProps ( String fileName ) throws Exception { Properties properties = new Properties ( ) ; InputStream inputStream = PropertyReader . class . getClassLoader ( ) . getResourceAsStream ( fileName ) ; if ( inputStream != null ) { try { properties . load ( inputStream ) ; } catch ( IOException e ...
Gets the props .
35,918
private static void onBind ( Class clazz ) { if ( ( ( MetamodelImpl ) em . getMetamodel ( ) ) . getEntityMetadataMap ( ) . isEmpty ( ) ) { EntityMetadata metadata = new EntityMetadata ( clazz ) ; metadata . setPersistenceUnit ( getPersistenceUnit ( ) ) ; setSchemaAndPU ( clazz , metadata ) ; new TableProcessor ( em . g...
On bind .
35,919
private static void setSchemaAndPU ( Class < ? > clazz , EntityMetadata metadata ) { Table table = clazz . getAnnotation ( Table . class ) ; if ( table != null ) { metadata . setTableName ( ! StringUtils . isBlank ( table . name ( ) ) ? table . name ( ) : clazz . getSimpleName ( ) ) ; String schemaStr = table . schema ...
Sets the schema and pu .
35,920
public Statement addWhereCondition ( AsPath asPath , String identifier , String colName , String val , String tableName ) { com . couchbase . client . java . query . dsl . Expression exp ; switch ( identifier ) { case "<" : exp = x ( colName ) . lt ( x ( val ) ) ; break ; case "<=" : exp = x ( colName ) . lte ( x ( val...
Adds the where condition .
35,921
public void addJoinColumns ( String joinColumn ) { if ( joinColumns == null || joinColumns . isEmpty ( ) ) { joinColumns = new HashSet < String > ( ) ; } joinColumns . add ( joinColumn ) ; }
Adds the join columns .
35,922
public void addInverseJoinColumns ( String inverseJoinColumn ) { if ( inverseJoinColumns == null || inverseJoinColumns . isEmpty ( ) ) { inverseJoinColumns = new HashSet < String > ( ) ; } inverseJoinColumns . add ( inverseJoinColumn ) ; }
Adds the inverse join columns .
35,923
public String getTableName ( ) { getEntityType ( ) ; return this . entityType != null && ! StringUtils . isBlank ( ( ( AbstractManagedType ) this . entityType ) . getTableName ( ) ) ? ( ( AbstractManagedType ) this . entityType ) . getTableName ( ) : tableName ; }
Gets the table name .
35,924
public String getSchema ( ) { getEntityType ( ) ; return this . entityType != null && ! StringUtils . isBlank ( ( ( AbstractManagedType ) this . entityType ) . getSchemaName ( ) ) ? ( ( AbstractManagedType ) this . entityType ) . getSchemaName ( ) : schema ; }
Gets the schema .
35,925
public void addRelation ( String property , Relation relation ) { relationsMap . put ( property , relation ) ; addRelationName ( relation ) ; }
Adds the relation .
35,926
private void addRelationName ( Relation rField ) { if ( rField != null && ! rField . isRelatedViaJoinTable ( ) ) { String relationName = getJoinColumnName ( rField . getProperty ( ) ) ; if ( rField . getProperty ( ) . isAnnotationPresent ( PrimaryKeyJoinColumn . class ) ) { relationName = this . getIdAttribute ( ) . ge...
Method to add specific relation name for given relational field .
35,927
private void addToRelationNameCollection ( String relationName ) { if ( relationNames == null ) { relationNames = new ArrayList < String > ( ) ; } if ( relationName != null ) { relationNames . add ( relationName ) ; } }
Adds relation name to relation name collection .
35,928
private String getJoinColumnName ( Field relation ) { String columnName = null ; JoinColumn ann = relation . getAnnotation ( JoinColumn . class ) ; if ( ann != null ) { columnName = ann . name ( ) ; } return StringUtils . isBlank ( columnName ) ? relation . getName ( ) : columnName ; }
Gets the relation field name .
35,929
public < E > ObjectGraph generateGraph ( E entity , PersistenceDelegator delegator , NodeState state ) { this . builder . assign ( this ) ; Node node = generate ( entity , delegator , delegator . getPersistenceCache ( ) , state ) ; this . builder . assignHeadNode ( node ) ; return this . builder . getGraph ( ) ; }
Generate entity graph and returns after assigning headnode . n
35,930
private Object onIfSharedByPK ( Relation relation , Object childObject , EntityMetadata childMetadata , Object entityId ) { if ( relation . isJoinedByPrimaryKey ( ) ) { PropertyAccessorHelper . setId ( childObject , childMetadata , entityId ) ; } return childObject ; }
Check and set if relation is set via primary key .
35,931
void onBuildChildNode ( Object childObject , EntityMetadata childMetadata , PersistenceDelegator delegator , PersistenceCache pc , Node node , Relation relation ) { Node childNode = generate ( childObject , delegator , pc , null ) ; if ( childNode != null ) { assignNodeLinkProperty ( node , relation , childNode ) ; } }
On building child node
35,932
private void assignNodeLinkProperty ( Node node , Relation relation , Node childNode ) { NodeLink nodeLink = new NodeLink ( node . getNodeId ( ) , childNode . getNodeId ( ) ) ; setLink ( node , relation , childNode , nodeLink ) ; }
On assigning node link properties
35,933
void setLink ( Node node , Relation relation , Node childNode , NodeLink nodeLink ) { nodeLink . setMultiplicity ( relation . getType ( ) ) ; EntityMetadata metadata = KunderaMetadataManager . getEntityMetadata ( node . getPersistenceDelegator ( ) . getKunderaMetadata ( ) , node . getDataClass ( ) ) ; nodeLink . setLin...
Set link property
35,934
static < S > String translate ( CriteriaQuery criteriaQuery ) { QueryBuilder builder = new CriteriaQueryTranslator . QueryBuilder ( ) ; Selection < S > select = criteriaQuery . getSelection ( ) ; if ( select != null ) { builder . appendSelectClause ( ) ; } if ( select . getClass ( ) . isAssignableFrom ( DefaultCompound...
Method to translate criteriaQuery into JPQL .
35,935
public static Block convertEtherBlockToKunderaBlock ( EthBlock block , boolean includeTransactions ) { Block kunderaBlk = new Block ( ) ; org . web3j . protocol . core . methods . response . EthBlock . Block blk = block . getBlock ( ) ; kunderaBlk . setAuthor ( blk . getAuthor ( ) ) ; kunderaBlk . setDifficulty ( blk ....
Convert ether block to kundera block .
35,936
public static Transaction convertEtherTxToKunderaTx ( TransactionResult transactionResult ) { Transaction kunderaTx = new Transaction ( ) ; TransactionObject txObj = ( TransactionObject ) transactionResult ; kunderaTx . setBlockHash ( txObj . getBlockHash ( ) ) ; kunderaTx . setBlockNumber ( txObj . getBlockNumberRaw (...
Convert ether tx to kundera tx .
35,937
public Object find ( Class entityClass , Object key ) { GraphDatabaseService graphDb = null ; if ( resource != null ) { graphDb = getConnection ( ) ; } if ( graphDb == null ) graphDb = factory . getConnection ( ) ; EntityMetadata m = KunderaMetadataManager . getEntityMetadata ( kunderaMetadata , entityClass ) ; Object ...
Finds an entity from graph database .
35,938
public void delete ( Object entity , Object key ) { checkActiveTransaction ( ) ; GraphDatabaseService graphDb = getConnection ( ) ; EntityMetadata m = KunderaMetadataManager . getEntityMetadata ( kunderaMetadata , entity . getClass ( ) ) ; Node node = mapper . searchNode ( key , m , graphDb , true ) ; if ( node != null...
Deletes an entity from database .
35,939
protected void onPersist ( EntityMetadata entityMetadata , Object entity , Object id , List < RelationHolder > rlHolders ) { if ( log . isDebugEnabled ( ) ) log . debug ( "Persisting " + entity ) ; checkActiveTransaction ( ) ; GraphDatabaseService graphDb = getConnection ( ) ; try { Node node = mapper . getNodeFromEnti...
Writes an entity to database .
35,940
public void bind ( TransactionResource resource ) { if ( resource != null && resource instanceof Neo4JTransaction ) { ( ( Neo4JTransaction ) resource ) . setGraphDb ( factory . getConnection ( ) ) ; this . resource = resource ; } else { throw new KunderaTransactionException ( "Invalid transaction resource provided:" + ...
Binds Transaction resource to this client .
35,941
public List < Object > executeLuceneQuery ( EntityMetadata m , String luceneQuery ) { log . info ( "Executing Lucene Query on Neo4J:" + luceneQuery ) ; GraphDatabaseService graphDb = getConnection ( ) ; List < Object > entities = new ArrayList < Object > ( ) ; if ( ! indexer . isNodeAutoIndexingEnabled ( graphDb ) && m...
Execute lucene query .
35,942
protected void addEntityFromIndexHits ( EntityMetadata m , List < Object > entities , IndexHits < Node > hits ) { for ( Node node : hits ) { if ( node != null ) { Object entity = getEntityWithAssociationFromNode ( m , node ) ; if ( entity != null ) { entities . add ( entity ) ; } } } }
Adds the entity from index hits .
35,943
private Object getEntityWithAssociationFromNode ( EntityMetadata m , Node node ) { Map < String , Object > relationMap = new HashMap < String , Object > ( ) ; Map < Long , Object > nodeIdToEntityMap = new HashMap < Long , Object > ( ) ; Object entity = mapper . getEntityFromNode ( node , m ) ; nodeIdToEntityMap . put (...
Gets the entity with association from node .
35,944
private void addDiscriminator ( Map < String , Object > values , EntityType entityType ) { String discrColumn = ( ( AbstractManagedType ) entityType ) . getDiscriminatorColumn ( ) ; String discrValue = ( ( AbstractManagedType ) entityType ) . getDiscriminatorValue ( ) ; if ( discrColumn != null && discrValue != null ) ...
Adds the discriminator .
35,945
private void addRelations ( List < RelationHolder > rlHolders , Map < String , Object > values ) { if ( rlHolders != null ) { for ( RelationHolder relation : rlHolders ) { values . put ( relation . getRelationName ( ) , relation . getRelationValue ( ) ) ; } } }
Adds the relations .
35,946
private void addSource ( Object entity , Map < String , Object > values , EntityType entityType ) { Set < Attribute > attributes = entityType . getAttributes ( ) ; for ( Attribute attrib : attributes ) { if ( ! attrib . isAssociation ( ) ) { Object value = PropertyAccessorHelper . getObject ( entity , ( Field ) attrib ...
Adds the source .
35,947
private void addSortOrder ( SearchRequestBuilder builder , KunderaQuery query , EntityMetadata entityMetadata ) { MetamodelImpl metaModel = ( MetamodelImpl ) kunderaMetadata . getApplicationMetadata ( ) . getMetamodel ( entityMetadata . getPersistenceUnit ( ) ) ; List < OrderByItem > orderList = KunderaQueryUtils . get...
Adds the sort order .
35,948
private void addFieldsToBuilder ( String [ ] fieldsToSelect , Class clazz , MetamodelImpl metaModel , SearchRequestBuilder builder ) { if ( fieldsToSelect != null && fieldsToSelect . length > 1 && ! ( fieldsToSelect [ 1 ] == null ) ) { logger . debug ( "Fields added in query are: " ) ; for ( int i = 1 ; i < fieldsToSel...
Adds the fields to builder
35,949
private String getKeyAsString ( Object id , EntityMetadata metadata , MetamodelImpl metaModel ) { if ( metaModel . isEmbeddable ( ( ( AbstractAttribute ) metadata . getIdAttribute ( ) ) . getBindableJavaType ( ) ) ) { return KunderaCoreUtils . prepareCompositeKey ( metadata , id ) ; } return id . toString ( ) ; }
Gets the key as string .
35,950
private void setRefreshIndexes ( Properties puProps , Map < String , Object > externalProperties ) { Object refreshIndexes = null ; if ( externalProperties . get ( ESConstants . KUNDERA_ES_REFRESH_INDEXES ) != null ) { refreshIndexes = externalProperties . get ( ESConstants . KUNDERA_ES_REFRESH_INDEXES ) ; } if ( refre...
Sets the refresh indexes .
35,951
private boolean isRefreshIndexes ( ) { if ( clientProperties != null ) { Object refreshIndexes = clientProperties . get ( ESConstants . ES_REFRESH_INDEXES ) ; if ( refreshIndexes != null && refreshIndexes instanceof Boolean ) { return ( boolean ) refreshIndexes ; } else { return Boolean . parseBoolean ( ( String ) refr...
Checks if is refresh indexes .
35,952
public List < ? > loadDataAndPopulateResults ( DataFrame dataFrame , EntityMetadata m , KunderaQuery kunderaQuery ) { if ( kunderaQuery != null && kunderaQuery . isAggregated ( ) ) { return dataFrame . collectAsList ( ) ; } else { return populateEntityObjectsList ( dataFrame , m ) ; } }
Load data and populate results .
35,953
private List < ? > populateEntityObjectsList ( DataFrame dataFrame , EntityMetadata m ) { List results = new ArrayList ( ) ; String [ ] columns = dataFrame . columns ( ) ; Map < String , Integer > map = createMapOfColumnIndex ( columns ) ; for ( Row row : dataFrame . collectAsList ( ) ) { Object entity = populateEntity...
Populate entity objects list .
35,954
private Object populateEntityFromDataFrame ( EntityMetadata m , Map < String , Integer > columnIndexMap , Row row ) { try { Object entity = KunderaCoreUtils . createNewInstance ( m . getEntityClazz ( ) ) ; Map < String , Object > relations = new HashMap < String , Object > ( ) ; if ( entity . getClass ( ) . isAssignabl...
Populate entity from data frame .
35,955
private Map < String , Integer > createMapOfColumnIndex ( String [ ] columns ) { int i = 0 ; Map < String , Integer > map = new HashMap < String , Integer > ( ) ; for ( String column : columns ) { map . put ( column , i ++ ) ; } return map ; }
Creates the map of column index .
35,956
public void buildFlushStack ( Node headNode , EventType eventType ) { if ( headNode != null ) { headNode . setTraversed ( false ) ; addNodesToFlushStack ( headNode , eventType ) ; } }
Builds the flush stack .
35,957
public void clearFlushStack ( ) { if ( stackQueue != null && ! stackQueue . isEmpty ( ) ) { stackQueue . clear ( ) ; } if ( joinTableDataCollection != null && ! joinTableDataCollection . isEmpty ( ) ) { joinTableDataCollection . clear ( ) ; } if ( eventLogQueue != null ) { eventLogQueue . clear ( ) ; } }
Empties Flush stack present in a PersistenceCache .
35,958
private void onRollBack ( PersistenceDelegator delegator , Map < Object , EventLog > eventCol ) { if ( eventCol != null && ! eventCol . isEmpty ( ) ) { Collection < EventLog > events = eventCol . values ( ) ; Iterator < EventLog > iter = events . iterator ( ) ; while ( iter . hasNext ( ) ) { try { EventLog event = iter...
On roll back .
35,959
private void addJoinTableData ( OPERATION operation , String schemaName , String joinTableName , String joinColumnName , String invJoinColumnName , Class < ? > entityClass , Object joinColumnValue , Set < Object > invJoinColumnValues ) { JoinTableData joinTableData = new JoinTableData ( operation , schemaName , joinTab...
Adds the join table data into map .
35,960
private void logEvent ( Node node , EventType eventType ) { EventLog log = new EventLog ( eventType , node ) ; eventLogQueue . onEvent ( log , eventType ) ; }
Log event .
35,961
public void persistJoinTable ( JoinTableData joinTableData ) { String joinTableName = joinTableData . getJoinTableName ( ) ; String invJoinColumnName = joinTableData . getInverseJoinColumnName ( ) ; Map < Object , Set < Object > > joinTableRecords = joinTableData . getJoinTableRecords ( ) ; EntityMetadata entityMetadat...
Persists a Join table record set into database .
35,962
protected final List < SuperColumn > loadSuperColumns ( String keyspace , String columnFamily , String rowId , String ... superColumnNames ) { if ( ! isOpen ( ) ) throw new PersistenceException ( "ThriftClient is closed." ) ; byte [ ] rowKey = rowId . getBytes ( ) ; SlicePredicate predicate = new SlicePredicate ( ) ; L...
Loads super columns from database .
35,963
public < E > List < E > getColumnsById ( String schemaName , String tableName , String pKeyColumnName , String columnName , Object pKeyColumnValue , Class columnJavaType ) { List < Object > foreignKeys = new ArrayList < Object > ( ) ; if ( getCqlVersion ( ) . equalsIgnoreCase ( CassandraConstants . CQL_VERSION_3_0 ) ) ...
Retrieves column for a given primary key .
35,964
public Object [ ] findIdsByColumn ( String schemaName , String tableName , String pKeyName , String columnName , Object columnValue , Class entityClazz ) { List < Object > rowKeys = new ArrayList < Object > ( ) ; if ( getCqlVersion ( ) . equalsIgnoreCase ( CassandraConstants . CQL_VERSION_3_0 ) ) { rowKeys = findIdsByC...
Retrieves IDs for a given column .
35,965
public List executeQuery ( Class clazz , List < String > relationalField , boolean isNative , String cqlQuery ) { if ( clazz == null ) { return super . executeScalarQuery ( cqlQuery ) ; } return super . executeSelectQuery ( clazz , relationalField , dataHandler , isNative , cqlQuery ) ; }
Query related methods .
35,966
private void createEmptyDataCollection ( ) { Class < ? > collectionClass = getRelation ( ) . getProperty ( ) . getType ( ) ; if ( collectionClass . isAssignableFrom ( Set . class ) ) { dataCollection = new HashSet ( ) ; } else if ( collectionClass . isAssignableFrom ( List . class ) ) { dataCollection = new ArrayList (...
Creates an a data collection which has no entity inside it
35,967
public Map < String , Metamodel > getMetamodelMap ( ) { if ( metamodelMap == null ) { metamodelMap = new HashMap < String , Metamodel > ( ) ; } return metamodelMap ; }
Gets the metamodel map .
35,968
public void setClazzToPuMap ( Map < String , List < String > > map ) { if ( clazzToPuMap == null ) { this . clazzToPuMap = map ; } else { clazzToPuMap . putAll ( map ) ; } }
Sets the clazz to pu map .
35,969
public List < String > getMappedPersistenceUnit ( Class < ? > clazz ) { return this . clazzToPuMap != null ? this . clazzToPuMap . get ( clazz . getName ( ) ) : null ; }
Gets the mapped persistence unit .
35,970
public String getMappedPersistenceUnit ( String clazzName ) { List < String > pus = clazzToPuMap . get ( clazzName ) ; final int _first = 0 ; String pu = null ; if ( pus != null && ! pus . isEmpty ( ) ) { if ( pus . size ( ) == 2 ) { onError ( clazzName ) ; } return pus . get ( _first ) ; } else { Set < String > mapped...
returns mapped persistence unit .
35,971
public void addQueryToCollection ( String queryName , String query , boolean isNativeQuery , Class clazz ) { if ( namedNativeQueries == null ) { namedNativeQueries = new ConcurrentHashMap < String , QueryWrapper > ( ) ; } if ( ! namedNativeQueries . containsKey ( queryName ) ) { namedNativeQueries . put ( queryName , n...
Adds parameterised query with given name into collection . Throws exception if duplicate name is provided .
35,972
public String getQuery ( String name ) { QueryWrapper wrapper = namedNativeQueries != null && name != null ? namedNativeQueries . get ( name ) : null ; return wrapper != null ? wrapper . getQuery ( ) : null ; }
Returns query interface .
35,973
public boolean isNative ( String name ) { QueryWrapper wrapper = namedNativeQueries != null && name != null ? namedNativeQueries . get ( name ) : null ; return wrapper != null ? wrapper . isNativeQuery ( ) : false ; }
Returns true if query is named native or native else false
35,974
public void fireEventListeners ( EntityMetadata metadata , Object entity , Class < ? > event ) { List < ? extends CallbackMethod > callBackMethods = metadata . getCallbackMethods ( event ) ; if ( null != callBackMethods && ! callBackMethods . isEmpty ( ) && null != entity ) { log . debug ( "Callback >> " + event . getS...
Fire event listeners .
35,975
private boolean isKeyword ( String token ) { for ( int i = 0 ; i < KunderaQuery . SINGLE_STRING_KEYWORDS . length ; i ++ ) { if ( token . equalsIgnoreCase ( KunderaQuery . SINGLE_STRING_KEYWORDS [ i ] ) ) { return true ; } } return false ; }
Method to detect whether this token is a keyword for JPQL Single - String .
35,976
static String likeToRegex ( String like ) { StringBuilder builder = new StringBuilder ( ) ; boolean wasPercent = false ; for ( int i = 0 ; i < like . length ( ) ; ++ i ) { char c = like . charAt ( i ) ; if ( isPlain ( c ) ) { if ( wasPercent ) { wasPercent = false ; builder . append ( ".*" ) ; } builder . append ( c ) ...
Like to regex .
35,977
private EntityMetadata belongsToPersistenceUnit ( EntityMetadata metadata ) { PersistenceUnitMetadata puMetadata = kunderaMetadata . getApplicationMetadata ( ) . getPersistenceUnitMetadata ( persistenceUnit ) ; String keyspace = puProperties != null ? ( String ) puProperties . get ( PersistenceProperties . KUNDERA_KEYS...
If parameterised metadata is not for intended persistence unit assign it to null .
35,978
private void initializePropertyReader ( ) { if ( propertyReader == null ) { propertyReader = new KuduDBPropertyReader ( externalProperties , kunderaMetadata . getApplicationMetadata ( ) . getPersistenceUnitMetadata ( getPersistenceUnit ( ) ) ) ; propertyReader . read ( getPersistenceUnit ( ) ) ; } }
Initialize property reader .
35,979
private static Document getDocument ( URL pathToPersistenceXml ) throws InvalidConfigurationException { InputStream is = null ; Document xmlRootNode = null ; try { if ( pathToPersistenceXml != null ) { URLConnection conn = pathToPersistenceXml . openConnection ( ) ; conn . setUseCaches ( false ) ; is = conn . getInputS...
Reads the persistence xml content into an object graph and validates it against the related xsd schema .
35,980
private static void validateDocumentAgainstSchema ( final Document xmlRootNode ) throws InvalidConfigurationException { final Element rootElement = xmlRootNode . getDocumentElement ( ) ; final String version = rootElement . getAttribute ( "version" ) ; String schemaFileName = "persistence_" + version . replace ( "." , ...
Validates an xml object graph against its schema . Therefore it reads the version from the root tag and tries to load the related xsd file from the classpath .
35,981
private static InputStream getStreamFromClasspath ( String fileName ) { String path = fileName ; InputStream dtdStream = PersistenceXMLLoader . class . getClassLoader ( ) . getResourceAsStream ( path ) ; return dtdStream ; }
Get stream from classpath .
35,982
public static PersistenceUnitTransactionType getTransactionType ( String elementContent ) { if ( elementContent == null || elementContent . isEmpty ( ) ) { return null ; } else if ( elementContent . equalsIgnoreCase ( "JTA" ) ) { return PersistenceUnitTransactionType . JTA ; } else if ( elementContent . equalsIgnoreCas...
Gets the transaction type .
35,983
private static String getElementContent ( Element element , String defaultStr ) { if ( element == null ) { return defaultStr ; } NodeList children = element . getChildNodes ( ) ; StringBuilder result = new StringBuilder ( "" ) ; for ( int i = 0 ; i < children . getLength ( ) ; i ++ ) { if ( children . item ( i ) . getN...
Get the content of the given element .
35,984
private static URL getPersistenceRootUrl ( URL url ) { String f = url . getFile ( ) ; f = parseFilePath ( f ) ; URL jarUrl = url ; try { if ( AllowedProtocol . isJarProtocol ( url . getProtocol ( ) ) ) { jarUrl = new URL ( f ) ; if ( jarUrl . getProtocol ( ) != null && AllowedProtocol . FILE . name ( ) . equals ( jarUr...
Returns persistence unit root url
35,985
private static String parseFilePath ( String file ) { final String excludePattern = "/META-INF/persistence.xml" ; file = file . substring ( 0 , file . length ( ) - excludePattern . length ( ) ) ; file = file . endsWith ( "!" ) ? file . substring ( 0 , file . length ( ) - 1 ) : file ; return file ; }
Parse and exclude path till META - INF
35,986
private static void onViaEmbeddable ( EntityType entityType , Attribute column , EntityMetadata m , Object entity , EmbeddableType embeddable , JsonObject jsonObj ) { Field embeddedField = ( Field ) column . getJavaMember ( ) ; JsonElement embeddedDocumentObject = jsonObj . get ( ( ( AbstractAttribute ) column ) . getJ...
On via embeddable .
35,987
static Object getObjectFromJson ( JsonObject jsonObj , Class clazz , Set < Attribute > columns ) { Object obj = KunderaCoreUtils . createNewInstance ( clazz ) ; for ( Attribute column : columns ) { JsonElement value = jsonObj . get ( ( ( AbstractAttribute ) column ) . getJPAColumnName ( ) ) ; setFieldValue ( obj , colu...
Gets the object from json .
35,988
private static JsonElement getJsonPrimitive ( Object value , Class clazz ) { if ( value != null ) { if ( clazz . isAssignableFrom ( Number . class ) || value instanceof Number ) { return new JsonPrimitive ( ( Number ) value ) ; } else if ( clazz . isAssignableFrom ( Boolean . class ) || value instanceof Boolean ) { ret...
Gets the json primitive .
35,989
private void getConfigurationObject ( ) { RDBMSPropertyReader reader = new RDBMSPropertyReader ( externalProperties , kunderaMetadata . getApplicationMetadata ( ) . getPersistenceUnitMetadata ( getPersistenceUnit ( ) ) ) ; this . conf = reader . load ( getPersistenceUnit ( ) ) ; }
Returns configuration object .
35,990
private SingularAttribute < ? super X , ? > getSingularAttribute ( String paramString , boolean checkValidity ) { SingularAttribute < ? super X , ? > attribute = getDeclaredSingularAttribute ( paramString , false ) ; try { if ( attribute == null && superClazzType != null ) { attribute = superClazzType . getSingularAttr...
Gets the singular attribute .
35,991
public void addSingularAttribute ( String attributeName , SingularAttribute < X , ? > attribute ) { if ( declaredSingluarAttribs == null ) { declaredSingluarAttribs = new HashMap < String , SingularAttribute < X , ? > > ( ) ; } declaredSingluarAttribs . put ( attributeName , attribute ) ; onValidateAttributeConstraints...
Adds the singular attribute .
35,992
public void addPluralAttribute ( String attributeName , PluralAttribute < X , ? , ? > attribute ) { if ( declaredPluralAttributes == null ) { declaredPluralAttributes = new HashMap < String , PluralAttribute < X , ? , ? > > ( ) ; } declaredPluralAttributes . put ( attributeName , attribute ) ; onValidateAttributeConstr...
Adds the plural attribute .
35,993
private void addSubManagedType ( ManagedType inheritedType ) { if ( Modifier . isAbstract ( this . getJavaType ( ) . getModifiers ( ) ) ) { subManagedTypes . add ( inheritedType ) ; } }
Adds the sub managed type .
35,994
private PluralAttribute < X , ? , ? > getDeclaredPluralAttribute ( String paramName ) { return declaredPluralAttributes != null ? declaredPluralAttributes . get ( paramName ) : null ; }
Gets the declared plural attribute .
35,995
private PluralAttribute < ? super X , ? , ? > getPluralAttriute ( String paramName ) { if ( superClazzType != null ) { return ( ( AbstractManagedType < ? super X > ) superClazzType ) . getDeclaredPluralAttribute ( paramName ) ; } return null ; }
Gets the plural attriute .
35,996
private < E > boolean onCheckCollectionAttribute ( PluralAttribute < ? super X , ? , ? > pluralAttribute , Class < E > paramClass ) { if ( pluralAttribute != null ) { if ( isCollectionAttribute ( pluralAttribute ) && isBindable ( pluralAttribute , paramClass ) ) { return true ; } } return false ; }
On check collection attribute .
35,997
private < E > boolean onCheckSetAttribute ( PluralAttribute < ? super X , ? , ? > pluralAttribute , Class < E > paramClass ) { if ( pluralAttribute != null ) { if ( isSetAttribute ( pluralAttribute ) && isBindable ( pluralAttribute , paramClass ) ) { return true ; } } return false ; }
On check set attribute .
35,998
private < E > boolean onCheckListAttribute ( PluralAttribute < ? super X , ? , ? > pluralAttribute , Class < E > paramClass ) { if ( pluralAttribute != null ) { if ( isListAttribute ( pluralAttribute ) && isBindable ( pluralAttribute , paramClass ) ) { return true ; } } return false ; }
On check list attribute .
35,999
private < V > boolean onCheckMapAttribute ( PluralAttribute < ? super X , ? , ? > pluralAttribute , Class < V > valueClazz ) { if ( pluralAttribute != null ) { if ( isMapAttribute ( pluralAttribute ) && isBindable ( pluralAttribute , valueClazz ) ) { return true ; } } return false ; }
On check map attribute .