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 ( ) ) { Object id = PropertyAccessorHelper . fromSourceToTargetClass ( ( ( AbstractAttribute ) m . getIdAttribute ( ) ) . getBindableJavaType ( ) , String . class , hit . getId ( ) ) ; map . put ( hit . getId ( ) , id ) ; } Map < String , Object > aggMap = esResponseReader . parseAggregations ( response , query , metaModel , m . getEntityClazz ( ) , m ) ; ListIterable < Expression > selectExpressionOrder = esResponseReader . getSelectExpressionOrder ( query ) ; Map < String , Object > resultMap = new HashMap < > ( ) ; resultMap . put ( Constants . AGGREGATIONS , aggMap ) ; resultMap . put ( Constants . PRIMARY_KEYS , map ) ; resultMap . put ( Constants . SELECT_EXPRESSION_ORDER , selectExpressionOrder ) ; return resultMap ; }
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 ( ) . toLowerCase ( ) ) . setTypes ( m . getEntityClazz ( ) . getSimpleName ( ) ) ; AggregationBuilder aggregation = query . buildAggregation ( kunderaQuery , m , filter ) ; if ( aggregation == null ) { builder . setQuery ( queryBuilder ) ; builder . setFrom ( firstResult ) ; builder . setSize ( maxResults ) ; addSortOrder ( builder , kunderaQuery , m , kunderaMetadata ) ; } else { log . debug ( "Aggregated query identified" ) ; builder . addAggregation ( aggregation ) ; if ( kunderaQuery . getResult ( ) . length == 1 || ( kunderaQuery . isSelectStatement ( ) && KunderaQueryUtils . hasGroupBy ( kunderaQuery . getJpqlExpression ( ) ) ) ) { builder . setSize ( 0 ) ; } } SearchResponse response = null ; log . debug ( "Query generated: " + builder ) ; try { response = builder . execute ( ) . actionGet ( ) ; log . debug ( "Query execution response: " + response ) ; } catch ( ElasticsearchException e ) { log . error ( "Exception occured while executing query on Elasticsearch." , e ) ; throw new KunderaException ( "Exception occured while executing query on Elasticsearch." , e ) ; } return response ; }
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 ) { LOGGER . error ( "Block number " + getBlockNumberWithRawData ( blk . getNumber ( ) ) + " is not stored. " , ex ) ; throw new KunderaException ( "Block number " + getBlockNumberWithRawData ( blk . getNumber ( ) ) + " is not stored. " , ex ) ; } for ( TransactionResult tx : block . getResult ( ) . getTransactions ( ) ) { persistTransactions ( EtherObjectConverterUtil . convertEtherTxToKunderaTx ( tx ) , blk . getNumber ( ) ) ; } em . clear ( ) ; }
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 ) { LOGGER . error ( "Transaction with hash " + tx . getHash ( ) + " is not stored. " , ex ) ; throw new KunderaException ( "transaction with hash " + tx . getHash ( ) + " is not stored. " , 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 find the EARLIEST block. " , ex ) ; } }
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 ( startBlockNumber . compareTo ( getFirstBlockNumber ( ) ) < 0 ) { LOGGER . error ( "start block number can't be smaller than EARLIEST block" ) ; throw new KunderaException ( "starting block number can't be smaller than EARLIEST block" ) ; } if ( endBlockNumber . compareTo ( getLatestBlockNumber ( ) ) > 0 ) { LOGGER . error ( "end block number can't be larger than LATEST block" ) ; throw new KunderaException ( "end block number can't be larger than LATEST block" ) ; } long diff = endBlockNumber . subtract ( startBlockNumber ) . longValue ( ) ; for ( long i = 0 ; i <= diff ; i ++ ) { EthBlock block = null ; BigInteger currentBlockNum = null ; try { currentBlockNum = startBlockNumber . add ( BigInteger . valueOf ( i ) ) ; block = web3j . ethGetBlockByNumber ( DefaultBlockParameter . valueOf ( currentBlockNum ) , true ) . send ( ) ; } catch ( IOException ex ) { LOGGER . error ( "Not able to find block" + currentBlockNum + ". " , ex ) ; throw new KunderaException ( "Not able to find block" + currentBlockNum + ". " , ex ) ; } persistBlocksAndTransactions ( block ) ; } }
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 ) ; throw new KunderaException ( "Specify - " + EthConstants . ETHEREUM_NODE_ENDPOINT + " in " + EthConstants . KUNDERA_ETHEREUM_PROPERTIES ) ; } else if ( endPoint . contains ( ".ipc" ) ) { String os = reader . getProperty ( EthConstants . ETHEREUM_NODE_OS ) ; LOGGER . info ( "Connecting using IPC socket. IPC Socket File location - " + endPoint ) ; if ( os != null && "windows" . equalsIgnoreCase ( os ) ) { web3j = Web3j . build ( new WindowsIpcService ( endPoint ) ) ; } else { web3j = Web3j . build ( new UnixIpcService ( endPoint ) ) ; } } else { LOGGER . info ( "Connecting via Endpoint - " + endPoint ) ; web3j = Web3j . build ( new HttpService ( endPoint ) ) ; } }
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 able to find dependency for Kundera " + props . get ( EthConstants . KUNDERA_DIALECT ) + " client." , ex ) ; throw new KunderaException ( "Not able to find dependency for Kundera " + props . get ( EthConstants . KUNDERA_DIALECT ) + " client." , ex ) ; } LOGGER . info ( "Kundera EMF created..." ) ; em = emf . createEntityManager ( ) ; LOGGER . info ( "Kundera EM created..." ) ; }
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 < String , Map < String , String > > ( ) ) ; loadClientProperties ( propertiesPath , clazzName , clientProperties , entityConfigurations ) ; if ( emf == null ) { StringBuilder puNames = new StringBuilder ( ) ; for ( Entry < String , Map < String , String > > entry : entityConfigurations . entrySet ( ) ) { if ( entry . getValue ( ) . get ( "kundera.pu" ) != null ) { puNames . append ( entry . getValue ( ) . get ( "kundera.pu" ) ) ; puNames . append ( "," ) ; } } if ( puNames . length ( ) > 0 ) { puNames . deleteCharAt ( puNames . length ( ) - 1 ) ; } try { if ( puNames . toString ( ) . isEmpty ( ) ) { emf = Persistence . createEntityManagerFactory ( "testPU" , entityConfigurations . get ( clazzName ) ) ; } else { emf = Persistence . createEntityManagerFactory ( puNames . toString ( ) ) ; } } catch ( Exception e ) { LOGGER . error ( "Unable to create Entity Manager Factory. Caused By: " , e ) ; throw new KunderaException ( "Unable to create Entity Manager Factory. Caused By: " , e ) ; } } return emf . createEntityManager ( ) ; }
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 ) ; clientProperties = JsonUtil . readJson ( inputStream , Map . class ) ; if ( clientProperties != null ) { if ( clientProperties . get ( "all" ) != null ) { entityConfigurations . put ( clazzName , clientProperties . get ( "all" ) ) ; } else { Iterator iter = clientProperties . keySet ( ) . iterator ( ) ; while ( iter . hasNext ( ) ) { Object key = iter . next ( ) ; if ( ( ( String ) key ) . indexOf ( ',' ) > 0 ) { StringTokenizer tokenizer = new StringTokenizer ( ( String ) key , "," ) ; while ( tokenizer . hasMoreElements ( ) ) { String token = tokenizer . nextToken ( ) ; entityConfigurations . put ( token , clientProperties . get ( key ) ) ; } } else { entityConfigurations . put ( ( String ) key , clientProperties . get ( key ) ) ; } } } } }
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 . getProperties ( ) ; String datastoreFilePath = null ; if ( externalProperties != null ) { datastoreFilePath = ( String ) externalProperties . get ( PersistenceProperties . KUNDERA_DATASTORE_FILE_PATH ) ; } if ( StringUtils . isBlank ( datastoreFilePath ) ) { datastoreFilePath = ( String ) props . get ( PersistenceProperties . KUNDERA_DATASTORE_FILE_PATH ) ; } if ( StringUtils . isBlank ( datastoreFilePath ) ) { throw new PersistenceUnitConfigurationException ( "For Neo4J, it's mandatory to specify kundera.datastore.file.path property in persistence.xml" ) ; } Neo4JSchemaMetadata nsmd = Neo4JPropertyReader . nsmd ; ClientProperties cp = nsmd != null ? nsmd . getClientProperties ( ) : null ; GraphDatabaseService graphDb = ( GraphDatabaseService ) getConnectionPoolOrConnection ( ) ; if ( cp != null && graphDb == null ) { DataStore dataStore = nsmd != null ? nsmd . getDataStore ( ) : null ; Properties properties = dataStore != null && dataStore . getConnection ( ) != null ? dataStore . getConnection ( ) . getProperties ( ) : null ; if ( properties != null ) { Map < String , String > config = new HashMap < String , String > ( ( Map ) properties ) ; GraphDatabaseBuilder builder = new GraphDatabaseFactory ( ) . newEmbeddedDatabaseBuilder ( datastoreFilePath ) ; builder . setConfig ( config ) ; graphDb = builder . newGraphDatabase ( ) ; } } if ( graphDb == null ) { graphDb = new GraphDatabaseFactory ( ) . newEmbeddedDatabase ( datastoreFilePath ) ; } return graphDb ; }
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 , primaryKey ) ; getPersistenceDelegator ( ) . populateClientProperties ( currentProperties ) ; return result ; }
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 ( currentProperties ) ; }
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 ) { LOGGER . error ( "JSON is null or empty." ) ; throw new KunderaException ( "JSON is null or empty." ) ; } } else { throw new KunderaException ( "Property file: [" + fileName + "] not found in the classpath" ) ; } return properties ; }
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 . getEntityManagerFactory ( ) . getProperties ( ) , ( ( EntityManagerFactoryImpl ) em . getEntityManagerFactory ( ) ) . getKunderaMetadataInstance ( ) ) . process ( clazz , metadata ) ; KunderaMetadata kunderaMetadata = ( ( EntityManagerFactoryImpl ) em . getEntityManagerFactory ( ) ) . getKunderaMetadataInstance ( ) ; new IndexProcessor ( kunderaMetadata ) . process ( clazz , metadata ) ; ApplicationMetadata appMetadata = kunderaMetadata . getApplicationMetadata ( ) ; ( ( MetamodelImpl ) em . getMetamodel ( ) ) . addEntityMetadata ( clazz , metadata ) ; ( ( MetamodelImpl ) em . getMetamodel ( ) ) . addEntityNameToClassMapping ( clazz . getSimpleName ( ) , clazz ) ; appMetadata . getMetamodelMap ( ) . put ( getPersistenceUnit ( ) , em . getMetamodel ( ) ) ; Map < String , List < String > > clazzToPuMap = new HashMap < String , List < String > > ( ) ; List < String > persistenceUnits = new ArrayList < String > ( ) ; persistenceUnits . add ( getPersistenceUnit ( ) ) ; clazzToPuMap . put ( clazz . getName ( ) , persistenceUnits ) ; appMetadata . setClazzToPuMap ( clazzToPuMap ) ; new SchemaConfiguration ( em . getEntityManagerFactory ( ) . getProperties ( ) , kunderaMetadata , getPersistenceUnit ( ) ) . configure ( ) ; } }
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 ( ) ; MetadataUtils . setSchemaAndPersistenceUnit ( metadata , schemaStr , em . getEntityManagerFactory ( ) . getProperties ( ) ) ; } else { metadata . setTableName ( clazz . getSimpleName ( ) ) ; metadata . setSchema ( ( String ) em . getEntityManagerFactory ( ) . getProperties ( ) . get ( "kundera.keyspace" ) ) ; } if ( metadata . getPersistenceUnit ( ) == null ) { metadata . setPersistenceUnit ( getPersistenceUnit ( ) ) ; } }
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 ) ) ; break ; case ">" : exp = x ( colName ) . gt ( x ( val ) ) ; break ; case ">=" : exp = x ( colName ) . gte ( x ( val ) ) ; break ; case "=" : exp = x ( colName ) . eq ( x ( val ) ) ; break ; default : LOGGER . error ( "Operator " + identifier + " is not supported in the JPA query for Couchbase." ) ; throw new KunderaException ( "Operator " + identifier + " is not supported in the JPA query for Couchbase." ) ; } return asPath . where ( exp . and ( x ( CouchbaseConstants . KUNDERA_ENTITY ) . eq ( x ( "'" + tableName ) + "'" ) ) ) ; }
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 ( ) . getName ( ) ; } addToRelationNameCollection ( relationName ) ; } }
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 . setLinkProperties ( getLinkProperties ( metadata , relation , node . getPersistenceDelegator ( ) . getKunderaMetadata ( ) ) ) ; childNode . addParentNode ( nodeLink , node ) ; node . addChildNode ( nodeLink , childNode ) ; }
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 ( DefaultCompoundSelection . class ) && ( ( CompoundSelection ) select ) . isCompoundSelection ( ) ) { List < Selection < ? > > selections = ( ( CompoundSelection ) select ) . getCompoundSelectionItems ( ) ; builder . appendMultiSelect ( selections ) ; } else if ( select instanceof AggregateExpression ) { builder . appendAggregate ( ( ( AggregateExpression ) select ) . getAggregation ( ) ) ; } else { String alias = select . getAlias ( ) ; if ( ! StringUtils . isEmpty ( alias ) ) { builder . appendAlias ( alias ) ; } Attribute attribute = ( ( DefaultPath ) select ) . getAttribute ( ) ; if ( attribute != null ) { builder . appendAttribute ( attribute ) ; } } Class < ? extends S > clazzType = select . getJavaType ( ) ; Set < Root < ? > > roots = criteriaQuery . getRoots ( ) ; Root < ? > from = roots . iterator ( ) . next ( ) ; Class entityClazz = from . getJavaType ( ) ; builder . appendFromClause ( ) ; builder . appendFrom ( entityClazz ) ; builder . appendAlias ( from . getAlias ( ) != null ? from . getAlias ( ) : select . getAlias ( ) ) ; Predicate where = criteriaQuery . getRestriction ( ) ; if ( where != null ) { builder . appendWhereClause ( ) ; List < Expression < Boolean > > expressions = where . getExpressions ( ) ; for ( Expression expr : expressions ) { builder . appendWhere ( expr , from . getAlias ( ) ) ; } } List < Order > orderings = criteriaQuery . getOrderList ( ) ; if ( orderings != null && ! orderings . isEmpty ( ) ) { builder . appendOrderClause ( where == null ) ; String alias = from . getAlias ( ) != null ? from . getAlias ( ) : select . getAlias ( ) ; builder . appendMultiOrdering ( orderings , alias ) ; } return builder . getQuery ( ) ; }
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 . getDifficultyRaw ( ) ) ; kunderaBlk . setExtraData ( blk . getExtraData ( ) ) ; kunderaBlk . setGasLimit ( blk . getGasLimitRaw ( ) ) ; kunderaBlk . setGasUsed ( blk . getGasUsedRaw ( ) ) ; kunderaBlk . setHash ( blk . getHash ( ) ) ; kunderaBlk . setLogsBloom ( blk . getLogsBloom ( ) ) ; kunderaBlk . setMiner ( blk . getMiner ( ) ) ; kunderaBlk . setMixHash ( blk . getMixHash ( ) ) ; kunderaBlk . setNonce ( blk . getNonceRaw ( ) ) ; kunderaBlk . setNumber ( blk . getNumberRaw ( ) ) ; kunderaBlk . setParentHash ( blk . getParentHash ( ) ) ; kunderaBlk . setReceiptsRoot ( blk . getReceiptsRoot ( ) ) ; kunderaBlk . setSealFields ( blk . getSealFields ( ) ) ; kunderaBlk . setSha3Uncles ( blk . getSha3Uncles ( ) ) ; kunderaBlk . setSize ( blk . getSizeRaw ( ) ) ; kunderaBlk . setStateRoot ( blk . getStateRoot ( ) ) ; kunderaBlk . setTimestamp ( blk . getTimestampRaw ( ) ) ; kunderaBlk . setTotalDifficulty ( blk . getTotalDifficultyRaw ( ) ) ; kunderaBlk . setTransactionsRoot ( blk . getTransactionsRoot ( ) ) ; kunderaBlk . setUncles ( blk . getUncles ( ) ) ; if ( includeTransactions ) { List < Transaction > kunderaTxs = new ArrayList < > ( ) ; List < TransactionResult > txResults = block . getBlock ( ) . getTransactions ( ) ; if ( txResults != null && ! txResults . isEmpty ( ) ) { for ( TransactionResult transactionResult : txResults ) { kunderaTxs . add ( convertEtherTxToKunderaTx ( transactionResult ) ) ; } kunderaBlk . setTransactions ( kunderaTxs ) ; } } return kunderaBlk ; }
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 ( ) ) ; kunderaTx . setCreates ( txObj . getCreates ( ) ) ; kunderaTx . setFrom ( txObj . getFrom ( ) ) ; kunderaTx . setGas ( txObj . getGasRaw ( ) ) ; kunderaTx . setGasPrice ( txObj . getGasPriceRaw ( ) ) ; kunderaTx . setHash ( txObj . getHash ( ) ) ; kunderaTx . setInput ( txObj . getInput ( ) ) ; kunderaTx . setNonce ( txObj . getNonceRaw ( ) ) ; kunderaTx . setPublicKey ( txObj . getPublicKey ( ) ) ; kunderaTx . setR ( txObj . getR ( ) ) ; kunderaTx . setRaw ( txObj . getRaw ( ) ) ; kunderaTx . setS ( txObj . getS ( ) ) ; kunderaTx . setTo ( txObj . getTo ( ) ) ; kunderaTx . setTransactionIndex ( txObj . getTransactionIndexRaw ( ) ) ; kunderaTx . setV ( txObj . getV ( ) ) ; kunderaTx . setValue ( txObj . getValueRaw ( ) ) ; return kunderaTx ; }
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 entity = null ; Node node = mapper . searchNode ( key , m , graphDb , true ) ; if ( node != null && ! ( ( Neo4JTransaction ) resource ) . containsNodeId ( node . getId ( ) ) ) { entity = getEntityWithAssociationFromNode ( m , node ) ; } return entity ; }
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 ) { if ( ! ( ( Neo4JTransaction ) resource ) . containsNodeId ( node . getId ( ) ) ) { node . delete ( ) ; indexer . deleteNodeIndex ( m , graphDb , node ) ; for ( Relationship relationship : node . getRelationships ( ) ) { relationship . delete ( ) ; indexer . deleteRelationshipIndex ( m , graphDb , relationship ) ; } ( ( Neo4JTransaction ) resource ) . addNodeId ( node . getId ( ) ) ; } } else { if ( log . isDebugEnabled ( ) ) log . debug ( "Entity to be deleted doesn't exist in graph. Doing nothing" ) ; } }
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 . getNodeFromEntity ( entity , id , graphDb , entityMetadata , isUpdate ) ; if ( node != null ) { MetamodelImpl metamodel = ( MetamodelImpl ) kunderaMetadata . getApplicationMetadata ( ) . getMetamodel ( getPersistenceUnit ( ) ) ; ( ( Neo4JTransaction ) resource ) . addProcessedNode ( id , node ) ; if ( ! rlHolders . isEmpty ( ) ) { for ( RelationHolder rh : rlHolders ) { EntityMetadata targetNodeMetadata = KunderaMetadataManager . getEntityMetadata ( kunderaMetadata , rh . getRelationValue ( ) . getClass ( ) ) ; Object targetNodeKey = PropertyAccessorHelper . getId ( rh . getRelationValue ( ) , targetNodeMetadata ) ; Node targetNode = null ; if ( isEntityForNeo4J ( targetNodeMetadata ) ) { targetNode = ( ( Neo4JTransaction ) resource ) . getProcessedNode ( targetNodeKey ) ; } else { if ( ! isUpdate ) { targetNode = mapper . createProxyNode ( id , targetNodeKey , graphDb , entityMetadata , targetNodeMetadata ) ; } } if ( targetNode != null ) { DynamicRelationshipType relType = DynamicRelationshipType . withName ( rh . getRelationName ( ) ) ; Relationship relationship = node . createRelationshipTo ( targetNode , relType ) ; Object relationshipObj = rh . getRelationVia ( ) ; if ( relationshipObj != null ) { mapper . populateRelationshipProperties ( entityMetadata , targetNodeMetadata , relationship , relationshipObj ) ; EntityMetadata relationMetadata = KunderaMetadataManager . getEntityMetadata ( kunderaMetadata , relationshipObj . getClass ( ) ) ; if ( ! isUpdate ) { indexer . indexRelationship ( relationMetadata , graphDb , relationship , metamodel ) ; } else { indexer . updateRelationshipIndex ( relationMetadata , graphDb , relationship , metamodel ) ; } } } } } if ( ! isUpdate ) { indexer . indexNode ( entityMetadata , graphDb , node , metamodel ) ; } else { indexer . updateNodeIndex ( entityMetadata , graphDb , node , metamodel ) ; } } } catch ( Exception e ) { log . error ( "Error while persisting entity " + entity + ", Caused by: " , e ) ; throw new PersistenceException ( e ) ; } }
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:" + resource + " Should have been an instance of :" + Neo4JTransaction . class ) ; } }
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 . isIndexable ( ) ) { Index < Node > nodeIndex = graphDb . index ( ) . forNodes ( m . getIndexName ( ) ) ; IndexHits < Node > hits = nodeIndex . query ( luceneQuery ) ; addEntityFromIndexHits ( m , entities , hits ) ; } else { ReadableIndex < Node > autoNodeIndex = graphDb . index ( ) . getNodeAutoIndexer ( ) . getAutoIndex ( ) ; IndexHits < Node > hits = autoNodeIndex . query ( luceneQuery ) ; addEntityFromIndexHits ( m , entities , hits ) ; } return entities ; }
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 ( node . getId ( ) , entity ) ; populateRelations ( m , entity , relationMap , node , nodeIdToEntityMap ) ; nodeIdToEntityMap . clear ( ) ; if ( ! relationMap . isEmpty ( ) && entity != null ) { return new EnhanceEntity ( entity , PropertyAccessorHelper . getId ( entity , m ) , relationMap ) ; } else { return entity ; } }
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 ) { values . put ( discrColumn , discrValue ) ; } }
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 . getJavaMember ( ) ) ; values . put ( ( ( AbstractAttribute ) attrib ) . getJPAColumnName ( ) , value ) ; } } }
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 . getOrderByItems ( query . getJpqlExpression ( ) ) ; for ( OrderByItem orderByItem : orderList ) { String ordering = orderByItem . getOrdering ( ) . toString ( ) ; if ( ordering . equalsIgnoreCase ( ESConstants . DEFAULT ) ) { ordering = Expression . ASC ; } builder . addSort ( KunderaCoreUtils . getJPAColumnName ( orderByItem . getExpression ( ) . toParsedText ( ) , entityMetadata , metaModel ) , SortOrder . valueOf ( ordering ) ) ; } }
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 < fieldsToSelect . length ; i ++ ) { logger . debug ( i + " : " + fieldsToSelect [ i ] ) ; builder = builder . addField ( ( ( AbstractAttribute ) metaModel . entity ( clazz ) . getAttribute ( fieldsToSelect [ i ] ) ) . getJPAColumnName ( ) ) ; } } }
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 ( refreshIndexes == null && puProps . get ( ESConstants . KUNDERA_ES_REFRESH_INDEXES ) != null ) { refreshIndexes = puProps . get ( ESConstants . KUNDERA_ES_REFRESH_INDEXES ) ; } if ( refreshIndexes != null ) { if ( refreshIndexes instanceof Boolean ) { this . setRereshIndexes = ( boolean ) refreshIndexes ; } else { this . setRereshIndexes = Boolean . parseBoolean ( ( String ) refreshIndexes ) ; } } }
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 ) refreshIndexes ) ; } } else { return this . setRereshIndexes ; } }
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 = populateEntityFromDataFrame ( m , map , row ) ; results . add ( entity ) ; } return results ; }
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 ( ) . isAssignableFrom ( EnhanceEntity . class ) ) { relations = ( ( EnhanceEntity ) entity ) . getRelations ( ) ; entity = ( ( EnhanceEntity ) entity ) . getEntity ( ) ; } MetamodelImpl metaModel = ( MetamodelImpl ) kunderaMetadata . getApplicationMetadata ( ) . getMetamodel ( m . getPersistenceUnit ( ) ) ; EntityType entityType = metaModel . entity ( m . getEntityClazz ( ) ) ; Set < Attribute > attributes = ( ( AbstractManagedType ) entityType ) . getAttributes ( ) ; for ( Attribute attribute : attributes ) { String columnName = getColumnName ( attribute ) ; Object columnValue = row . get ( columnIndexMap . get ( columnName ) ) ; if ( columnValue != null ) { Object value = PropertyAccessorHelper . fromSourceToTargetClass ( attribute . getJavaType ( ) , columnValue . getClass ( ) , columnValue ) ; PropertyAccessorHelper . set ( entity , ( Field ) attribute . getJavaMember ( ) , value ) ; } } SingularAttribute attrib = m . getIdAttribute ( ) ; Object rowKey = PropertyAccessorHelper . getObject ( entity , ( Field ) attrib . getJavaMember ( ) ) ; if ( ! relations . isEmpty ( ) ) { return new EnhanceEntity ( entity , rowKey , relations ) ; } return entity ; } catch ( PropertyAccessException e1 ) { throw new RuntimeException ( e1 ) ; } }
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 . next ( ) ; Node node = event . getNode ( ) ; Class clazz = node . getDataClass ( ) ; EntityMetadata metadata = KunderaMetadataManager . getEntityMetadata ( delegator . getKunderaMetadata ( ) , clazz ) ; Client client = delegator . getClient ( metadata ) ; if ( node . isProcessed ( ) && ( ! delegator . isTransactionInProgress ( ) || MetadataUtils . defaultTransactionSupported ( metadata . getPersistenceUnit ( ) , delegator . getKunderaMetadata ( ) ) ) ) { if ( node . getOriginalNode ( ) == null ) { Object entityId = node . getEntityId ( ) ; client . remove ( node . getData ( ) , entityId ) ; } else { client . persist ( node . getOriginalNode ( ) ) ; } } event = null ; } catch ( Exception ex ) { log . warn ( "Caught exception during rollback, Caused by:" , ex ) ; } } } eventCol = null ; }
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 , joinTableName , joinColumnName , invJoinColumnName , entityClass ) ; joinTableData . addJoinTableRecord ( joinColumnValue , invJoinColumnValues ) ; joinTableDataCollection . add ( joinTableData ) ; }
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 entityMetadata = KunderaMetadataManager . getEntityMetadata ( kunderaMetadata , joinTableData . getEntityClass ( ) ) ; Connection conn = null ; try { conn = getConnection ( ) ; if ( isCql3Enabled ( entityMetadata ) ) { persistJoinTableByCql ( joinTableData , conn . getClient ( ) ) ; } else { KunderaCoreUtils . printQuery ( "Persist join table:" + joinTableName , showQuery ) ; for ( Object key : joinTableRecords . keySet ( ) ) { PropertyAccessor accessor = PropertyAccessorFactory . getPropertyAccessor ( ( Field ) entityMetadata . getIdAttribute ( ) . getJavaMember ( ) ) ; byte [ ] rowKey = accessor . toBytes ( key ) ; Set < Object > values = joinTableRecords . get ( key ) ; List < Column > columns = new ArrayList < Column > ( ) ; List < Mutation > insertionList = new ArrayList < Mutation > ( ) ; Class columnType = null ; for ( Object value : values ) { Column column = new Column ( ) ; column . setName ( PropertyAccessorFactory . STRING . toBytes ( invJoinColumnName + Constants . JOIN_COLUMN_NAME_SEPARATOR + value ) ) ; column . setValue ( PropertyAccessorHelper . getBytes ( value ) ) ; column . setTimestamp ( generator . getTimestamp ( ) ) ; columnType = value . getClass ( ) ; columns . add ( column ) ; Mutation mut = new Mutation ( ) ; mut . setColumn_or_supercolumn ( new ColumnOrSuperColumn ( ) . setColumn ( column ) ) ; insertionList . add ( mut ) ; } createIndexesOnColumns ( entityMetadata , joinTableName , columns , columnType ) ; Map < String , List < Mutation > > columnFamilyValues = new HashMap < String , List < Mutation > > ( ) ; columnFamilyValues . put ( joinTableName , insertionList ) ; Map < ByteBuffer , Map < String , List < Mutation > > > mulationMap = new HashMap < ByteBuffer , Map < String , List < Mutation > > > ( ) ; mulationMap . put ( ByteBuffer . wrap ( rowKey ) , columnFamilyValues ) ; conn . getClient ( ) . set_keyspace ( entityMetadata . getSchema ( ) ) ; conn . getClient ( ) . batch_mutate ( mulationMap , getConsistencyLevel ( ) ) ; } } } catch ( InvalidRequestException e ) { log . error ( "Error while inserting record into join table, Caused by: ." , e ) ; throw new PersistenceException ( e ) ; } catch ( TException e ) { log . error ( "Error while inserting record into join table, Caused by: ." , e ) ; throw new PersistenceException ( e ) ; } finally { releaseConnection ( conn ) ; } }
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 ( ) ; List < ByteBuffer > columnNames = new ArrayList < ByteBuffer > ( ) ; for ( String superColumnName : superColumnNames ) { KunderaCoreUtils . printQuery ( "Fetch superColumn:" + superColumnName , showQuery ) ; columnNames . add ( ByteBuffer . wrap ( superColumnName . getBytes ( ) ) ) ; } predicate . setColumn_names ( columnNames ) ; ColumnParent parent = new ColumnParent ( columnFamily ) ; List < ColumnOrSuperColumn > coscList ; Connection conn = null ; try { conn = getConnection ( ) ; coscList = conn . getClient ( ) . get_slice ( ByteBuffer . wrap ( rowKey ) , parent , predicate , getConsistencyLevel ( ) ) ; } catch ( InvalidRequestException e ) { log . error ( "Error while getting super columns for row Key {} , Caused by: ." , rowId , e ) ; throw new EntityReaderException ( e ) ; } catch ( UnavailableException e ) { log . error ( "Error while getting super columns for row Key {} , Caused by: ." , rowId , e ) ; throw new EntityReaderException ( e ) ; } catch ( TimedOutException e ) { log . error ( "Error while getting super columns for row Key {} , Caused by: ." , rowId , e ) ; throw new EntityReaderException ( e ) ; } catch ( TException e ) { log . error ( "Error while getting super columns for row Key {} , Caused by: ." , rowId , e ) ; throw new EntityReaderException ( e ) ; } finally { releaseConnection ( conn ) ; } List < SuperColumn > superColumns = ThriftDataResultHelper . transformThriftResult ( coscList , ColumnFamilyType . SUPER_COLUMN , null ) ; return superColumns ; }
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 ) ) { foreignKeys = getColumnsByIdUsingCql ( schemaName , tableName , pKeyColumnName , columnName , pKeyColumnValue , columnJavaType ) ; } else { byte [ ] rowKey = CassandraUtilities . toBytes ( pKeyColumnValue ) ; if ( rowKey != null ) { SlicePredicate predicate = new SlicePredicate ( ) ; SliceRange sliceRange = new SliceRange ( ) ; sliceRange . setStart ( new byte [ 0 ] ) ; sliceRange . setFinish ( new byte [ 0 ] ) ; predicate . setSlice_range ( sliceRange ) ; ColumnParent parent = new ColumnParent ( tableName ) ; List < ColumnOrSuperColumn > results ; Connection conn = null ; try { conn = getConnection ( ) ; results = conn . getClient ( ) . get_slice ( ByteBuffer . wrap ( rowKey ) , parent , predicate , getConsistencyLevel ( ) ) ; } catch ( InvalidRequestException e ) { log . error ( "Error while getting columns for row Key {} , Caused by: ." , pKeyColumnValue , e ) ; throw new EntityReaderException ( e ) ; } catch ( UnavailableException e ) { log . error ( "Error while getting columns for row Key {} , Caused by: ." , pKeyColumnValue , e ) ; throw new EntityReaderException ( e ) ; } catch ( TimedOutException e ) { log . error ( "Error while getting columns for row Key {} , Caused by: ." , pKeyColumnValue , e ) ; throw new EntityReaderException ( e ) ; } catch ( TException e ) { log . error ( "Error while getting columns for row Key {} , Caused by: ." , pKeyColumnValue , e ) ; throw new EntityReaderException ( e ) ; } finally { releaseConnection ( conn ) ; } List < Column > columns = ThriftDataResultHelper . transformThriftResult ( results , ColumnFamilyType . COLUMN , null ) ; foreignKeys = dataHandler . getForeignKeysFromJoinTable ( columnName , columns , columnJavaType ) ; } } return ( List < E > ) foreignKeys ; }
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 = findIdsByColumnUsingCql ( schemaName , tableName , pKeyName , columnName , columnValue , entityClazz ) ; } else { EntityMetadata metadata = KunderaMetadataManager . getEntityMetadata ( kunderaMetadata , entityClazz ) ; SlicePredicate slicePredicate = new SlicePredicate ( ) ; slicePredicate . setSlice_range ( new SliceRange ( ByteBufferUtil . EMPTY_BYTE_BUFFER , ByteBufferUtil . EMPTY_BYTE_BUFFER , false , Integer . MAX_VALUE ) ) ; String childIdStr = PropertyAccessorHelper . getString ( columnValue ) ; IndexExpression ie = new IndexExpression ( UTF8Type . instance . decompose ( columnName + Constants . JOIN_COLUMN_NAME_SEPARATOR + childIdStr ) , IndexOperator . EQ , UTF8Type . instance . decompose ( childIdStr ) ) ; List < IndexExpression > expressions = new ArrayList < IndexExpression > ( ) ; expressions . add ( ie ) ; IndexClause ix = new IndexClause ( ) ; ix . setStart_key ( ByteBufferUtil . EMPTY_BYTE_BUFFER ) ; ix . setCount ( Integer . MAX_VALUE ) ; ix . setExpressions ( expressions ) ; ColumnParent columnParent = new ColumnParent ( tableName ) ; Connection conn = null ; try { conn = getConnection ( ) ; List < KeySlice > keySlices = conn . getClient ( ) . get_indexed_slices ( columnParent , ix , slicePredicate , getConsistencyLevel ( ) ) ; rowKeys = ThriftDataResultHelper . getRowKeys ( keySlices , metadata ) ; } catch ( InvalidRequestException e ) { log . error ( "Error while fetching key slices of column family {} for column name {} , Caused by: ." , tableName , columnName , e ) ; throw new KunderaException ( e ) ; } catch ( UnavailableException e ) { log . error ( "Error while fetching key slices of column family {} for column name {} , Caused by: ." , tableName , columnName , e ) ; throw new KunderaException ( e ) ; } catch ( TimedOutException e ) { log . error ( "Error while fetching key slices of column family {} for column name {} , Caused by: ." , tableName , columnName , e ) ; throw new KunderaException ( e ) ; } catch ( TException e ) { log . error ( "Error while fetching key slices of column family {} for column name {} , Caused by: ." , tableName , columnName , e ) ; throw new KunderaException ( e ) ; } finally { releaseConnection ( conn ) ; } } if ( rowKeys != null && ! rowKeys . isEmpty ( ) ) { return rowKeys . toArray ( new Object [ 0 ] ) ; } if ( log . isInfoEnabled ( ) ) { log . info ( "No record found!, returning null." ) ; } return null ; }
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 > mappedClasses = this . clazzToPuMap . keySet ( ) ; boolean found = false ; for ( String clazz : mappedClasses ) { if ( found && clazz . endsWith ( "." + clazzName ) ) { onError ( clazzName ) ; } else if ( clazz . endsWith ( "." + clazzName ) || clazz . endsWith ( "$" + clazzName ) ) { pu = clazzToPuMap . get ( clazz ) . get ( _first ) ; found = true ; } } } return pu ; }
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 , new QueryWrapper ( queryName , query , isNativeQuery , clazz ) ) ; } else if ( queryName != null && ! getQuery ( queryName ) . equals ( query ) ) { logger . error ( "Duplicate named/native query with name:" + queryName + "found! Already there is a query with same name:" + namedNativeQueries . get ( queryName ) ) ; throw new ApplicationLoaderException ( "Duplicate named/native query with name:" + queryName + "found! Already there is a query with same name:" + namedNativeQueries . get ( queryName ) ) ; } }
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 . getSimpleName ( ) + " on " + metadata . getEntityClazz ( ) . getName ( ) ) ; for ( CallbackMethod callback : callBackMethods ) { log . debug ( "Firing >> " + callback ) ; callback . invoke ( entity ) ; } } }
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 ) ; } else if ( wasPercent ) { wasPercent = false ; if ( c == '%' ) { builder . append ( '%' ) ; } else { builder . append ( ".*" ) . append ( c ) ; } } else { if ( c == '%' ) { wasPercent = true ; } else { builder . append ( '\\' ) . append ( c ) ; } } } if ( wasPercent ) { builder . append ( ".*" ) ; } return builder . toString ( ) ; }
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_KEYSPACE ) : null ; keyspace = keyspace == null ? puMetadata . getProperty ( PersistenceProperties . KUNDERA_KEYSPACE ) : keyspace ; if ( metadata . getPersistenceUnit ( ) != null && ! metadata . getPersistenceUnit ( ) . equals ( persistenceUnit ) || ( keyspace != null && metadata . getSchema ( ) != null && ! metadata . getSchema ( ) . equals ( keyspace ) ) ) { metadata = null ; } else { applyMetadataChanges ( metadata ) ; } return metadata ; }
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 . getInputStream ( ) ; } if ( is == null ) { throw new IOException ( "Failed to obtain InputStream from url: " + pathToPersistenceXml ) ; } xmlRootNode = parseDocument ( is ) ; validateDocumentAgainstSchema ( xmlRootNode ) ; } catch ( IOException e ) { throw new InvalidConfigurationException ( e ) ; } finally { if ( is != null ) { try { is . close ( ) ; } catch ( IOException ex ) { log . warn ( "Input stream could not be closed after parsing persistence.xml, caused by: {}" , ex ) ; } } } return xmlRootNode ; }
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 ( "." , "_" ) + ".xsd" ; try { final List validationErrors = new ArrayList ( ) ; final String schemaLanguage = XMLConstants . W3C_XML_SCHEMA_NS_URI ; final StreamSource streamSource = new StreamSource ( getStreamFromClasspath ( schemaFileName ) ) ; final Schema schemaDefinition = SchemaFactory . newInstance ( schemaLanguage ) . newSchema ( streamSource ) ; final Validator schemaValidator = schemaDefinition . newValidator ( ) ; schemaValidator . setErrorHandler ( new ErrorLogger ( "XML InputStream" , validationErrors ) ) ; schemaValidator . validate ( new DOMSource ( xmlRootNode ) ) ; if ( ! validationErrors . isEmpty ( ) ) { final String exceptionText = "persistence.xml is not conform against the supported schema definitions." ; throw new InvalidConfigurationException ( exceptionText ) ; } } catch ( SAXException e ) { final String exceptionText = "Error validating persistence.xml against schema defintion, caused by: " ; throw new InvalidConfigurationException ( exceptionText , e ) ; } catch ( IOException e ) { final String exceptionText = "Error opening xsd schema file. The given persistence.xml descriptor version " + version + " might not be supported yet." ; throw new InvalidConfigurationException ( exceptionText , e ) ; } }
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 . equalsIgnoreCase ( "RESOURCE_LOCAL" ) ) { return PersistenceUnitTransactionType . RESOURCE_LOCAL ; } else { throw new PersistenceException ( "Unknown TransactionType: " + elementContent ) ; } }
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 ) . getNodeType ( ) == Node . TEXT_NODE || children . item ( i ) . getNodeType ( ) == Node . CDATA_SECTION_NODE ) { result . append ( children . item ( i ) . getNodeValue ( ) ) ; } } return result . toString ( ) . trim ( ) ; }
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 ( jarUrl . getProtocol ( ) . toUpperCase ( ) ) && StringUtils . contains ( f , " " ) ) { jarUrl = new File ( f ) . toURI ( ) . toURL ( ) ; } } else if ( AllowedProtocol . isValidProtocol ( url . getProtocol ( ) ) ) { if ( StringUtils . contains ( f , " " ) ) { jarUrl = new File ( f ) . toURI ( ) . toURL ( ) ; } else { jarUrl = new File ( f ) . toURL ( ) ; } } } catch ( MalformedURLException mex ) { log . error ( "Error during getPersistenceRootUrl(), Caused by: {}." , mex ) ; throw new IllegalArgumentException ( "Invalid jar URL[] provided!" + url ) ; } return jarUrl ; }
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 ) . getJPAColumnName ( ) ) ; if ( ! column . isCollection ( ) ) { PropertyAccessorHelper . set ( entity , embeddedField , getObjectFromJson ( embeddedDocumentObject . getAsJsonObject ( ) , ( ( AbstractAttribute ) column ) . getBindableJavaType ( ) , embeddable . getAttributes ( ) ) ) ; } }
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 , column , value ) ; } return obj ; }
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 ) { return new JsonPrimitive ( ( Boolean ) value ) ; } else if ( clazz . isAssignableFrom ( Character . class ) || value instanceof Character ) { return new JsonPrimitive ( ( Character ) value ) ; } else if ( clazz . isAssignableFrom ( byte [ ] . class ) || value instanceof byte [ ] ) { return new JsonPrimitive ( PropertyAccessorFactory . STRING . fromBytes ( String . class , ( byte [ ] ) value ) ) ; } else { return new JsonPrimitive ( PropertyAccessorHelper . getString ( value ) ) ; } } }
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 . getSingularAttribute ( paramString ) ; } } catch ( IllegalArgumentException iaex ) { attribute = null ; onValidity ( paramString , checkValidity , attribute ) ; } onValidity ( paramString , checkValidity , attribute ) ; return attribute ; }
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 ( ( Field ) attribute . getJavaMember ( ) ) ; onEmbeddableAttribute ( ( Field ) attribute . getJavaMember ( ) ) ; }
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 ) ; onValidateAttributeConstraints ( ( Field ) attribute . getJavaMember ( ) ) ; onEmbeddableAttribute ( ( Field ) attribute . getJavaMember ( ) ) ; }
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 .