idx
int64
0
41.2k
question
stringlengths
73
5.81k
target
stringlengths
5
918
35,400
public static void createDesignDocumentIfNotExist ( HttpClient httpClient , HttpHost httpHost , Gson gson , String tableName , String schemaName , String viewName , List < String > columns ) throws URISyntaxException , UnsupportedEncodingException , IOException , ClientProtocolException { URI uri ; HttpResponse respons...
Creates the design document if not exist .
35,401
private static CouchDBDesignDocument getDesignDocument ( HttpClient httpClient , HttpHost httpHost , Gson gson , String tableName , String schemaName ) { HttpResponse response = null ; try { String id = CouchDBConstants . DESIGN + tableName ; URI uri = new URI ( CouchDBConstants . PROTOCOL , null , httpHost . getHostNa...
Gets the design document .
35,402
private void createIndexOnTable ( TableInfo tableInfo ) { List < IndexInfo > indexColumns = tableInfo . getColumnsToBeIndexed ( ) ; for ( IndexInfo indexInfo : indexColumns ) { if ( indexInfo . getIndexType ( ) != null && indexInfo . getIndexType ( ) . toLowerCase ( ) . equals ( Constants . COMPOSITE ) ) { String [ ] c...
Creates the index on table .
35,403
private String buildCreateDDLQuery ( TableInfo tableInfo ) { String statement ; boolean flag = false ; StringBuilder compoundKeys = null ; StringBuilder builder = new StringBuilder ( ) ; builder . append ( "CREATE TABLE " ) ; builder . append ( tableInfo . getTableName ( ) ) ; builder . append ( Constants . OPEN_ROUND_...
Builds the create ddl query .
35,404
private String buildAlterDDLQuery ( TableInfo tableInfo , Map < String , String > newColumns ) { String statement ; StringBuilder builder = new StringBuilder ( ) ; builder . append ( "ALTER TABLE " ) ; builder . append ( tableInfo . getTableName ( ) ) ; builder . append ( Constants . OPEN_ROUND_BRACKET ) ; for ( Map . ...
Builds the alter ddl query .
35,405
public Node createProxyNode ( Object sourceNodeId , Object targetNodeId , GraphDatabaseService graphDb , EntityMetadata sourceEntityMetadata , EntityMetadata targetEntityMetadata ) { String sourceNodeIdColumnName = ( ( AbstractAttribute ) sourceEntityMetadata . getIdAttribute ( ) ) . getJPAColumnName ( ) ; String targe...
Create Proxy nodes into Neo4J . Proxy nodes are defined as nodes in Neo4J that refer to a record in some other database . They cater to polyglot persistence cases .
35,406
private void populateNodeProperties ( Object entity , EntityMetadata m , Node node ) { MetamodelImpl metaModel = ( MetamodelImpl ) kunderaMetadata . getApplicationMetadata ( ) . getMetamodel ( m . getPersistenceUnit ( ) ) ; EntityType entityType = metaModel . entity ( m . getEntityClazz ( ) ) ; Set < Attribute > attrib...
Populates Node properties from Entity object
35,407
private String serializeIdAttributeValue ( final EntityMetadata m , MetamodelImpl metaModel , Object id ) { if ( ! metaModel . isEmbeddable ( m . getIdAttribute ( ) . getBindableJavaType ( ) ) ) { return null ; } Class < ? > embeddableClass = m . getIdAttribute ( ) . getBindableJavaType ( ) ; String idUniqueValue = "" ...
Prepares ID column value for embedded IDs by combining its attributes
35,408
private Object deserializeIdAttributeValue ( final EntityMetadata m , String idValue ) { if ( idValue == null ) { return null ; } Class < ? > embeddableClass = m . getIdAttribute ( ) . getBindableJavaType ( ) ; Object embeddedObject = embeddedObject = KunderaCoreUtils . createNewInstance ( embeddableClass ) ; List < St...
Prepares Embedded ID field from value prepared via serializeIdAttributeValue method .
35,409
public Object toNeo4JProperty ( Object source ) { if ( source instanceof BigDecimal || source instanceof BigInteger ) { return source . toString ( ) ; } else if ( ( source instanceof Calendar ) || ( source instanceof GregorianCalendar ) ) { return PropertyAccessorHelper . fromSourceToTargetClass ( String . class , Date...
Converts a given field value to an object that is Neo4J compatible
35,410
public Node searchNode ( Object key , EntityMetadata m , GraphDatabaseService graphDb , boolean skipProxy ) { Node node = null ; String idColumnName = ( ( AbstractAttribute ) m . getIdAttribute ( ) ) . getJPAColumnName ( ) ; final MetamodelImpl metaModel = ( MetamodelImpl ) kunderaMetadata . getApplicationMetadata ( ) ...
Searches a node from the database for a given key
35,411
protected Node getMatchingNodeFromIndexHits ( IndexHits < Node > nodesFound , boolean skipProxy ) { Node node = null ; try { if ( nodesFound == null || nodesFound . size ( ) == 0 || ! nodesFound . hasNext ( ) ) { return null ; } else { if ( skipProxy ) node = getNonProxyNode ( nodesFound ) ; else node = nodesFound . ne...
Fetches first Non - proxy node from Index Hits
35,412
private Node getNonProxyNode ( IndexHits < Node > nodesFound ) { Node node = null ; if ( nodesFound . hasNext ( ) ) { node = nodesFound . next ( ) ; } else { return null ; } try { Object proxyNodeProperty = node . getProperty ( PROXY_NODE_TYPE_KEY ) ; } catch ( NotFoundException e ) { return node ; } catch ( IllegalSta...
Fetches Non - proxy nodes from index hits
35,413
protected void exportSchema ( final String persistenceUnit , List < TableInfo > tables ) { this . puMetadata = kunderaMetadata . getApplicationMetadata ( ) . getPersistenceUnitMetadata ( persistenceUnit ) ; String paramString = externalProperties != null ? ( String ) externalProperties . get ( PersistenceProperties . K...
Export schema handles the handleOperation method .
35,414
private void handleOperations ( List < TableInfo > tableInfos ) { SchemaOperationType operationType = SchemaOperationType . getInstance ( operation ) ; switch ( operationType ) { case createdrop : create_drop ( tableInfos ) ; break ; case create : create ( tableInfos ) ; break ; case update : update ( tableInfos ) ; br...
Handle operations .
35,415
public static PersistenceUnitMetadata getPersistenceUnitMetadata ( final KunderaMetadata kunderaMetadata , String persistenceUnit ) { if ( persistenceUnit != null && kunderaMetadata != null ) { return kunderaMetadata . getApplicationMetadata ( ) . getPersistenceUnitMetadata ( persistenceUnit ) ; } return null ; }
Gets the persistence unit metadata .
35,416
public static EntityMetadata getEntityMetadata ( final KunderaMetadata kunderaMetadata , Class entityClass ) { if ( entityClass == null ) { throw new KunderaException ( "Invalid class provided " + entityClass ) ; } List < String > persistenceUnits = kunderaMetadata . getApplicationMetadata ( ) . getMappedPersistenceUni...
Finds ands returns Entity metadata for a given array of PUs .
35,417
public void updateNodeIndex ( EntityMetadata entityMetadata , GraphDatabaseService graphDb , Node node , MetamodelImpl metaModel ) { if ( ! isNodeAutoIndexingEnabled ( graphDb ) && entityMetadata . isIndexable ( ) ) { Index < Node > nodeIndex = graphDb . index ( ) . forNodes ( entityMetadata . getIndexName ( ) ) ; node...
If node auto - indexing is disabled Update index for this node manually
35,418
public void updateRelationshipIndex ( EntityMetadata entityMetadata , GraphDatabaseService graphDb , Relationship relationship , MetamodelImpl metaModel ) { if ( ! isRelationshipAutoIndexingEnabled ( graphDb ) && entityMetadata . isIndexable ( ) ) { Index < Relationship > relationshipIndex = graphDb . index ( ) . forRe...
If relationship auto - indexing is disabled Update index for this relationship manually
35,419
public static Class < ? > getValidationClassInstance ( Class < ? > dataType , boolean isCql3Enabled ) { resetMapperForCQL3 ( isCql3Enabled ) ; Class < ? > validation_class ; validation_class = validationClassMapper . get ( dataType ) ; if ( validation_class == null ) { if ( dataType . isEnum ( ) ) { validation_class = ...
Gets the validation class instance .
35,420
public static TypeSerializer < ? > getValidationSerializerClassInstance ( Class < ? > dataType , boolean isCql3Enabled ) { resetMapperForCQL3 ( isCql3Enabled ) ; TypeSerializer < ? > validation_class ; validation_class = validationSerializerClassMapper . get ( dataType ) ; if ( validation_class == null ) { if ( dataTyp...
Gets the validation serializer class instance .
35,421
public static String getValueTypeName ( Class < ? > dataType , List < Class < ? > > genericClasses , boolean isCql3Enabled ) throws SyntaxException , ConfigurationException , IllegalArgumentException , IllegalAccessException , NoSuchFieldException , SecurityException { String valueType ; Class < ? > validation_class = ...
Gets the value type name .
35,422
private static void resetMapperForCQL3 ( boolean isCql3Enabled ) { if ( isCql3Enabled ) { validationClassMapper . put ( Byte . class , Int32Type . class ) ; validationClassMapper . put ( byte . class , Int32Type . class ) ; validationClassMapper . put ( Short . class , Int32Type . class ) ; validationClassMapper . put ...
Reset mapper for cq l3 .
35,423
private static void resetMapperForThrift ( boolean isCql3Enabled ) { if ( isCql3Enabled ) { validationClassMapper . put ( Byte . class , BytesType . class ) ; validationClassMapper . put ( byte . class , BytesType . class ) ; validationClassMapper . put ( Short . class , IntegerType . class ) ; validationClassMapper . ...
Reset mapper for thrift .
35,424
public static CassandraType getCassandraDataTypeClass ( Class clazz ) { if ( clazz . isEnum ( ) ) { return CassandraType . STRING ; } return typeToClazz . get ( clazz ) ; }
Gets the cassandra data type class .
35,425
public static Collection marshalCollection ( Class cassandraTypeClazz , Collection result , Class clazz , Class resultTypeClass ) { Collection mappedCollection = result ; if ( cassandraTypeClazz . isAssignableFrom ( BytesType . class ) ) { mappedCollection = ( Collection ) PropertyAccessorHelper . getObject ( resultTyp...
Marshal collection .
35,426
private void validateQueryResults ( String query , N1qlQueryResult result ) { LOGGER . debug ( "Query output status: " + result . finalSuccess ( ) ) ; if ( ! result . finalSuccess ( ) ) { StringBuilder errorBuilder = new StringBuilder ( ) ; for ( JsonObject obj : result . errors ( ) ) { errorBuilder . append ( obj . to...
Validate query results .
35,427
public static void populateCompoundKey ( DBObject dbObj , EntityMetadata m , MetamodelImpl metaModel , Object id ) { EmbeddableType compoundKey = metaModel . embeddable ( m . getIdAttribute ( ) . getBindableJavaType ( ) ) ; BasicDBObject compoundKeyObj = new BasicDBObject ( ) ; compoundKeyObj = getCompoundKeyColumns ( ...
Populate compound key .
35,428
public static BasicDBObject getCompoundKeyColumns ( EntityMetadata m , Object id , EmbeddableType compoundKey , MetamodelImpl metaModel ) { BasicDBObject compoundKeyObj = new BasicDBObject ( ) ; Set < Attribute > attribs = compoundKey . getDeclaredAttributes ( ) ; Field [ ] fields = m . getIdAttribute ( ) . getBindable...
Gets the compound key columns .
35,429
public static Object populateValue ( Object valObj , Class clazz ) { if ( isUTF8Value ( clazz ) || clazz . isEnum ( ) ) { return valObj . toString ( ) ; } else if ( ( valObj instanceof Calendar ) || ( valObj instanceof GregorianCalendar ) ) { return ( ( Calendar ) valObj ) . getTime ( ) ; } else if ( CollectionExpressi...
Populate value .
35,430
private static boolean isUTF8Value ( Class < ? > clazz ) { return ( clazz . isAssignableFrom ( BigDecimal . class ) ) || ( clazz . isAssignableFrom ( BigInteger . class ) || ( clazz . isAssignableFrom ( String . class ) ) || ( clazz . isAssignableFrom ( char . class ) ) || ( clazz . isAssignableFrom ( Character . class...
Checks if is UT f8 value .
35,431
public static Object getTranslatedObject ( Object value , Class < ? > sourceClass , Class < ? > targetClass ) { if ( sourceClass . isAssignableFrom ( Date . class ) ) { value = PropertyAccessorHelper . fromDate ( targetClass , sourceClass , value ) ; } else { value = PropertyAccessorHelper . fromSourceToTargetClass ( t...
Gets the translated object .
35,432
public static DBObject getDBObject ( EntityMetadata m , String tableName , Map < String , DBObject > dbObjects , MetamodelImpl metaModel , Object id ) { tableName = tableName != null ? tableName : m . getTableName ( ) ; DBObject dbObj = dbObjects . get ( tableName ) ; if ( dbObj == null ) { dbObj = new BasicDBObject ( ...
Gets the DB object .
35,433
public static String calculateMD5 ( Object val ) { MessageDigest md = null ; try { md = MessageDigest . getInstance ( "MD5" ) ; } catch ( NoSuchAlgorithmException e ) { logger . error ( "Unable to calculate MD5 for file, Caused By: " , e ) ; } md . update ( ( byte [ ] ) val ) ; byte [ ] digest = md . digest ( ) ; retur...
Calculate m d5 .
35,434
private void setNext ( ) { initial = true ; try { if ( next != null ) { jar . closeEntry ( ) ; } next = null ; do { next = jar . getNextJarEntry ( ) ; } while ( next != null && ( next . isDirectory ( ) || ( filter == null || ! filter . accepts ( next . getName ( ) ) ) ) ) ; if ( next == null ) { close ( ) ; } } catch (...
Sets the next .
35,435
protected int onExecuteUpdate ( ) { EntityMetadata m = getEntityMetadata ( ) ; Client client = m != null ? persistenceDelegeator . getClient ( m ) : persistenceDelegeator . getClient ( kunderaQuery . getPersistenceUnit ( ) ) ; externalProperties = ( ( CassandraClientBase ) client ) . getExternalProperties ( ) ; Applica...
On executeUpdate .
35,436
private boolean isQueryConvertibleToCQL ( KunderaQuery kunderaQuery ) { EntityMetadata m = kunderaQuery . getEntityMetadata ( ) ; if ( kunderaQuery . isUpdateClause ( ) && m . isCounterColumnType ( ) ) return false ; List < String > opsNotAllowed = Arrays . asList ( new String [ ] { ">" , "<" , ">=" , "<=" } ) ; boolea...
Checks whether a given JPA DML query is convertible to CQL .
35,437
private void addCompositeIdToColumns ( MetamodelImpl metamodel , EmbeddableType compoundKey , List < String > columns , Field field ) { if ( ! ReflectUtils . isTransientOrStatic ( field ) ) { Attribute compositeColumn = compoundKey . getAttribute ( field . getName ( ) ) ; if ( compositeColumn . getJavaType ( ) . isAnno...
Adds the composite id to columns .
35,438
Map < Boolean , List < IndexClause > > prepareIndexClause ( EntityMetadata m , boolean isQueryForInvertedIndex ) { IndexClause indexClause = new IndexClause ( new ArrayList < IndexExpression > ( ) , ByteBufferUtil . EMPTY_BYTE_BUFFER , maxResult ) ; List < IndexClause > clauses = new ArrayList < IndexClause > ( ) ; Lis...
Prepare index clause .
35,439
ByteBuffer getBytesValue ( String jpaFieldName , EntityMetadata m , Object value ) { Attribute idCol = m . getIdAttribute ( ) ; MetamodelImpl metaModel = ( MetamodelImpl ) kunderaMetadata . getApplicationMetadata ( ) . getMetamodel ( m . getPersistenceUnit ( ) ) ; EntityType entity = metaModel . entity ( m . getEntityC...
Returns bytes value for given value .
35,440
public String onQueryOverCQL3 ( EntityMetadata m , Client client , MetamodelImpl metaModel , List < String > relations ) { Class compoundKeyClass = m . getIdAttribute ( ) . getBindableJavaType ( ) ; EmbeddableType compoundKey = null ; String idColumn ; if ( metaModel . isEmbeddable ( compoundKeyClass ) ) { compoundKey ...
On query over composite columns .
35,441
private String setSelectQuery ( List < String > columns ) { if ( columns != null && ! columns . isEmpty ( ) ) { return CQLTranslator . SELECT_QUERY ; } if ( kunderaQuery . isAggregated ( ) ) { Expression selectExpression = ( ( SelectClause ) kunderaQuery . getSelectStatement ( ) . getSelectClause ( ) ) . getSelectExpre...
Sets the select query .
35,442
private void onLimit ( StringBuilder builder ) { if ( Integer . MAX_VALUE != maxResult ) { builder . append ( CQLTranslator . LIMIT ) ; builder . append ( isSingleResult ? 1 : this . maxResult ) ; } }
Add provided max result limit .
35,443
private boolean getCompoundKeyColumn ( MetamodelImpl metamodel , EmbeddableType keyObj , StringBuilder builder , boolean isPresent , CQLTranslator translator , String fieldName , String condition , List < Object > value , boolean useInClause ) { fieldName = fieldName . substring ( fieldName . indexOf ( "." ) + 1 ) ; if...
Gets the compound key column .
35,444
private StringBuilder appendOrderByClause ( MetamodelImpl metaModel , EntityMetadata m , EmbeddableType keyObj , StringBuilder builder , CQLTranslator translator ) { List < SortOrdering > orders = getKunderaQuery ( ) . getOrdering ( ) ; if ( orders != null ) { builder . append ( CQLTranslator . SPACE_STRING ) ; builder...
Append order by clause .
35,445
private boolean extractCompositeKey ( MetamodelImpl metaModel , EmbeddableType keyObj , StringBuilder builder , CQLTranslator translator , List < Object > value , boolean useInClause , Map < Attribute , List < Object > > columnValues , Field field ) { Attribute compositeColumn = keyObj . getAttribute ( field . getName ...
Extract composite key .
35,446
private boolean buildWhereClause ( StringBuilder builder , boolean isPresent , CQLTranslator translator , String condition , List < Object > value , boolean useInClause , AbstractAttribute idAttributeColumn , String columnName , boolean useToken ) { if ( value . isEmpty ( ) ) { isPresent = appendIn ( builder , translat...
Builds the where clause .
35,447
private boolean appendIn ( StringBuilder builder , CQLTranslator translator , String columnName ) { boolean isPresent ; isPresent = true ; translator . ensureCase ( builder , columnName , false ) ; builder . append ( " IN " ) ; return isPresent ; }
Append in .
35,448
private boolean appendInClause ( StringBuilder queryBuilder , CQLTranslator translator , List < Object > value , Class fieldClazz , String columnName , boolean isPresent ) { isPresent = appendIn ( queryBuilder , translator , columnName ) ; queryBuilder . append ( "(" ) ; for ( Object objectvalue : value ) { translator ...
Append in clause .
35,449
void addWhereClause ( StringBuilder builder ) { if ( ! getKunderaQuery ( ) . getFilterClauseQueue ( ) . isEmpty ( ) ) { builder . append ( CQLTranslator . ADD_WHERE_CLAUSE ) ; } }
Adds the where clause .
35,450
public void setRelationalEntities ( List enhanceEntities , Client client , EntityMetadata m ) { super . setRelationEntities ( enhanceEntities , client , m ) ; }
Sets the relational entities .
35,451
public String createUpdateQuery ( KunderaQuery kunderaQuery ) { EntityMetadata metadata = kunderaQuery . getEntityMetadata ( ) ; MetamodelImpl metaModel = ( MetamodelImpl ) kunderaMetadata . getApplicationMetadata ( ) . getMetamodel ( metadata . getPersistenceUnit ( ) ) ; CQLTranslator translator = new CQLTranslator ( ...
Create Update CQL query from a given JPA query .
35,452
public String createDeleteQuery ( KunderaQuery kunderaQuery ) { EntityMetadata metadata = kunderaQuery . getEntityMetadata ( ) ; MetamodelImpl metaModel = ( MetamodelImpl ) kunderaMetadata . getApplicationMetadata ( ) . getMetamodel ( metadata . getPersistenceUnit ( ) ) ; CQLTranslator translator = new CQLTranslator ( ...
Create Delete query from a given JPA query .
35,453
private void buildWhereClause ( KunderaQuery kunderaQuery , EntityMetadata metadata , MetamodelImpl metaModel , CQLTranslator translator , StringBuilder builder ) { for ( Object clause : kunderaQuery . getFilterClauseQueue ( ) ) { FilterClause filterClause = ( FilterClause ) clause ; Field f = ( Field ) metaModel . ent...
Builds where Clause .
35,454
private String getColumnName ( EntityMetadata metadata , String property ) { MetamodelImpl metaModel = ( MetamodelImpl ) kunderaMetadata . getApplicationMetadata ( ) . getMetamodel ( metadata . getPersistenceUnit ( ) ) ; String jpaColumnName = null ; if ( property . equals ( ( ( AbstractAttribute ) metadata . getIdAttr...
Gets column name for a given field name .
35,455
public static void populateColumnAndSuperColumnMaps ( EntityMetadata m , Map < String , Field > columnNameToFieldMap , Map < String , Field > superColumnNameToFieldMap , final KunderaMetadata kunderaMetadata ) { getEmbeddableType ( m , columnNameToFieldMap , superColumnNameToFieldMap , kunderaMetadata ) ; }
Populate column and super column maps .
35,456
public static Map < String , Field > createColumnsFieldMap ( EntityMetadata m , EmbeddableType superColumn ) { Map < String , Field > columnNameToFieldMap = new HashMap < String , Field > ( ) ; Set < Attribute > attributes = superColumn . getAttributes ( ) ; for ( Attribute column : attributes ) { columnNameToFieldMap ...
Creates the columns field map .
35,457
public static Map < String , Field > createSuperColumnsFieldMap ( final EntityMetadata m , final KunderaMetadata kunderaMetadata ) { Map < String , Field > superColumnNameToFieldMap = new HashMap < String , Field > ( ) ; getEmbeddableType ( m , null , superColumnNameToFieldMap , kunderaMetadata ) ; return superColumnNa...
Creates the super columns field map .
35,458
public static Collection getEmbeddedCollectionInstance ( Field embeddedCollectionField ) { Collection embeddedCollection = null ; Class embeddedCollectionFieldClass = embeddedCollectionField . getType ( ) ; if ( embeddedCollection == null || embeddedCollection . isEmpty ( ) ) { if ( embeddedCollectionFieldClass . equal...
Gets the embedded collection instance .
35,459
public static Object getEmbeddedGenericObjectInstance ( Field embeddedCollectionField ) { Class < ? > embeddedClass = PropertyAccessorHelper . getGenericClass ( embeddedCollectionField ) ; Object embeddedObject = null ; try { embeddedClass . getConstructor ( ) ; embeddedObject = embeddedClass . newInstance ( ) ; } catc...
Gets the embedded generic object instance .
35,460
public static String getEmbeddedCollectionPrefix ( String embeddedCollectionName ) { return embeddedCollectionName . substring ( 0 , embeddedCollectionName . indexOf ( Constants . EMBEDDED_COLUMN_NAME_DELIMITER ) ) ; }
Gets the embedded collection prefix .
35,461
public static String getEmbeddedCollectionPostfix ( String embeddedCollectionName ) { return embeddedCollectionName . substring ( embeddedCollectionName . lastIndexOf ( Constants . EMBEDDED_COLUMN_NAME_DELIMITER ) + 1 , embeddedCollectionName . length ( ) ) ; }
Gets the embedded collection postfix .
35,462
public static String serializeKeys ( Set < String > foreignKeys ) { if ( null == foreignKeys || foreignKeys . isEmpty ( ) ) { return null ; } StringBuilder sb = new StringBuilder ( ) ; for ( String key : foreignKeys ) { if ( sb . length ( ) > 0 ) { sb . append ( Constants . FOREIGN_KEY_SEPARATOR ) ; } sb . append ( key...
Creates a string representation of a set of foreign keys by combining them together separated by ~ character .
35,463
public static Set < String > deserializeKeys ( String foreignKeys ) { Set < String > keys = new HashSet < String > ( ) ; if ( null == foreignKeys || foreignKeys . isEmpty ( ) ) { return keys ; } String array [ ] = foreignKeys . split ( Constants . FOREIGN_KEY_SEPARATOR ) ; for ( String element : array ) { keys . add ( ...
Splits foreign keys into Set .
35,464
public static void setSchemaAndPersistenceUnit ( EntityMetadata m , String schemaStr , Map puProperties ) { if ( schemaStr . indexOf ( Constants . SCHEMA_PERSISTENCE_UNIT_SEPARATOR ) > 0 ) { String schemaName = null ; if ( puProperties != null ) { schemaName = ( String ) puProperties . get ( PersistenceProperties . KUN...
Sets the schema and persistence unit .
35,465
public static String getMappedName ( EntityMetadata parentMetadata , Relation relation , final KunderaMetadata kunderaMetadata ) { if ( relation != null ) { String joinColumn = relation . getJoinColumnName ( kunderaMetadata ) ; if ( joinColumn == null ) { Class clazz = relation . getTargetEntity ( ) ; EntityMetadata me...
Returns mapped relational name in case of bi directional mapping it will return back pKey name of associated entity .
35,466
public static String getEnclosingEmbeddedFieldName ( EntityMetadata m , String criteria , boolean viaColumnName , final KunderaMetadata kunderaMetadata ) { String enclosingEmbeddedFieldName = null ; StringTokenizer strToken = new StringTokenizer ( criteria , "." ) ; String embeddableAttributeName = null ; String embedd...
Gets the enclosing document name .
35,467
public static boolean defaultTransactionSupported ( final String persistenceUnit , final KunderaMetadata kunderaMetadata ) { PersistenceUnitMetadata puMetadata = KunderaMetadataManager . getPersistenceUnitMetadata ( kunderaMetadata , persistenceUnit ) ; String txResource = puMetadata . getProperty ( PersistenceProperti...
If client specific to parameterized persistence unit does not support transaction return true else will return false .
35,468
public static boolean isBasicElementCollectionField ( Field collectionField ) { if ( ! Collection . class . isAssignableFrom ( collectionField . getType ( ) ) && ! Map . class . isAssignableFrom ( collectionField . getType ( ) ) ) { return false ; } List < Class < ? > > genericClasses = PropertyAccessorHelper . getGene...
Checks whether a given field is Element collection field of BASIC type
35,469
public static boolean containsBasicElementCollectionField ( final EntityMetadata m , final KunderaMetadata kunderaMetadata ) { Metamodel metaModel = kunderaMetadata . getApplicationMetadata ( ) . getMetamodel ( m . getPersistenceUnit ( ) ) ; EntityType entityType = metaModel . entity ( m . getEntityClazz ( ) ) ; Iterat...
Checks whether an entity with given metadata contains a collection field
35,470
public static boolean onCheckValidationConstraints ( Field attribute ) { return attribute . isAnnotationPresent ( AssertFalse . class ) || attribute . isAnnotationPresent ( AssertTrue . class ) || attribute . isAnnotationPresent ( DecimalMax . class ) || attribute . isAnnotationPresent ( DecimalMin . class ) || attribu...
Returns true if an entity contains attributes with validation constraints enabled
35,471
public static RelationMetadataProcessor getRelationMetadataProcessor ( Field relationField , KunderaMetadata kunderaMetadata ) { RelationMetadataProcessor relProcessor = null ; if ( relationField . isAnnotationPresent ( OneToOne . class ) ) { relProcessor = new OneToOneRelationMetadataProcessor ( kunderaMetadata ) ; } ...
Gets the relation metadata processor .
35,472
public static boolean onAutoGenerateId ( Field idField , Object idValue ) { if ( idField . isAnnotationPresent ( GeneratedValue . class ) ) { return ! isIdSet ( idValue , idField ) ; } return false ; }
Validates and set id in case not set and intended for auto generation .
35,473
private Map < String , Object > parseInsertIntoQuery ( String query ) { Map < String , Object > persistDetails = new HashMap < String , Object > ( ) ; String insertReg = "(?i)^insert\\s+into\\s+(\\S+)\\s+(?:as\\s+(\\S+)\\s+)?FROM\\s+\\((.*)\\)$" ; Pattern r = Pattern . compile ( insertReg ) ; Matcher m = r . matcher ( ...
Parses the insert into query .
35,474
private Map < String , Object > parsePersistClause ( String persistClause , Map < String , Object > persistDetails ) throws KunderaException { Pattern pattern = Pattern . compile ( "^([^.]+)\\.(?:([^.]+)\\.([^.]+)|\\[([^\\]]+)\\])$" ) ; Matcher matcher = pattern . matcher ( persistClause ) ; if ( matcher . find ( ) ) {...
Parses the persist clause .
35,475
public int getDataFrameSize ( DataFrame dataFrame ) { long l = dataFrame != null ? dataFrame . count ( ) : 0 ; if ( l < Integer . MIN_VALUE || l > Integer . MAX_VALUE ) { logger . error ( l + " cannot be cast to int without changing its value." ) ; return 0 ; } return ( int ) l ; }
Gets the data frame size .
35,476
private DataFrame getDataFrameToPersist ( String query , String subQuery ) { EntityMetadata entityMetadata = getEntityMetadata ( ) ; Client client = entityMetadata != null ? persistenceDelegeator . getClient ( entityMetadata ) : persistenceDelegeator . getClient ( kunderaQuery . getPersistenceUnit ( ) ) ; return ( ( Sp...
Gets the data frame to persist .
35,477
boolean isAggregatedQuery ( ) { if ( kunderaQuery . getSelectStatement ( ) != null ) { Expression exp = ( ( SelectClause ) kunderaQuery . getSelectStatement ( ) . getSelectClause ( ) ) . getSelectExpression ( ) ; return AggregateFunction . class . isAssignableFrom ( exp . getClass ( ) ) ; } else { return false ; } }
Checks if is aggregated query .
35,478
private boolean isCountQuery ( ) { if ( getKunderaQuery ( ) . getSelectStatement ( ) != null ) { final Expression selectClause = getKunderaQuery ( ) . getSelectStatement ( ) . getSelectClause ( ) ; if ( selectClause instanceof SelectClause ) { final Expression expression = ( ( SelectClause ) selectClause ) . getSelectE...
Checks if is count query .
35,479
private void populateQueryComponents ( EntityMetadata m , QueryComponent sq ) { boolean hasChildren = false ; if ( sq . children != null && sq . children . size ( ) > 0 ) { hasChildren = true ; for ( QueryComponent subQ : sq . children ) { populateQueryComponents ( m , subQ ) ; } } if ( sq . clauses . size ( ) > 0 || h...
Populate query components .
35,480
private static QueryComponent getQueryComponent ( Queue filterClauseQueue ) { QueryComponent subQuery = new QueryComponent ( ) ; QueryComponent currentSubQuery = subQuery ; for ( Object object : filterClauseQueue ) { if ( object instanceof FilterClause ) { currentSubQuery . clauses . add ( object ) ; } else if ( object...
Gets the query component .
35,481
public BasicDBObject createMongoQuery ( EntityMetadata m , Queue filterClauseQueue ) { QueryComponent sq = getQueryComponent ( filterClauseQueue ) ; populateQueryComponents ( m , sq ) ; return sq . actualQuery == null ? new BasicDBObject ( ) : sq . actualQuery ; }
Creates the mongo query .
35,482
private BasicDBObject getKeys ( EntityMetadata m , String [ ] columns ) { BasicDBObject keys = new BasicDBObject ( ) ; if ( columns != null && columns . length > 0 ) { MetamodelImpl metaModel = ( MetamodelImpl ) kunderaMetadata . getApplicationMetadata ( ) . getMetamodel ( m . getPersistenceUnit ( ) ) ; EntityType enti...
Gets the keys .
35,483
private BasicDBObject createAggregation ( EntityMetadata metadata ) { if ( kunderaQuery . getSelectStatement ( ) != null ) { Metamodel metaModel = kunderaMetadata . getApplicationMetadata ( ) . getMetamodel ( metadata . getPersistenceUnit ( ) ) ; EntityType entityType = metaModel . entity ( metadata . getEntityClazz ( ...
Get the aggregation object .
35,484
private void buildAggregation ( DBObject group , Expression expression , EntityMetadata metadata , EntityType entityType , boolean hasLob ) { if ( expression instanceof AggregateFunction ) { AggregateFunction aggregateFunction = ( AggregateFunction ) expression ; String identifier = aggregateFunction . getIdentifier ( ...
Build the aggregation parameters .
35,485
private BasicDBObject getOrderByClause ( final EntityMetadata metadata ) { BasicDBObject orderByClause = null ; Metamodel metaModel = kunderaMetadata . getApplicationMetadata ( ) . getMetamodel ( metadata . getPersistenceUnit ( ) ) ; EntityType entityType = metaModel . entity ( metadata . getEntityClazz ( ) ) ; Abstrac...
Prepare order by clause .
35,486
private int handleSpecialFunctions ( ) { boolean needsSpecialAttention = false ; outer : for ( UpdateClause c : kunderaQuery . getUpdateClauseQueue ( ) ) { for ( int i = 0 ; i < FUNCTION_KEYWORDS . length ; i ++ ) { if ( c . getValue ( ) instanceof String ) { String func = c . getValue ( ) . toString ( ) ; func = func ...
Handle special functions .
35,487
private String getColumnName ( EntityMetadata metadata , EntityType entityType , String property ) { String columnName = null ; if ( property . indexOf ( "." ) > 0 ) { property = property . substring ( ( kunderaQuery . getEntityAlias ( ) + "." ) . length ( ) ) ; } try { columnName = ( ( AbstractAttribute ) entityType ....
Gets the column name .
35,488
public static String createLikeRegex ( String expr , boolean ignoreCase ) { String regex = createRegex ( expr , ignoreCase ) ; regex = regex . replace ( "_" , "." ) . replace ( "%" , ".*?" ) ; return regex ; }
Create regular expression equivalent to any like operator string match function .
35,489
public static String createRegex ( String value , boolean ignoreCase ) { if ( value == null ) { throw new IllegalArgumentException ( "String cannot be null" ) ; } int len = value . length ( ) ; if ( len == 0 ) { return "" ; } StringBuilder sb = new StringBuilder ( len * 2 ) ; if ( ignoreCase ) { sb . append ( "(?i)" ) ...
Generates the regular expression for matching string for like operator .
35,490
private URL loadResource ( String configurationResourceName ) { ClassLoader standardClassloader = ClassLoaderUtil . getStandardClassLoader ( ) ; URL url = null ; if ( standardClassloader != null ) { url = standardClassloader . getResource ( configurationResourceName ) ; } if ( url == null ) { url = this . getClass ( ) ...
Load resource .
35,491
private void setScanCriteria ( Scan scan , String columnFamily , List < Map < String , Object > > columnsToOutput , Filter filter ) { if ( filter != null ) { scan . setFilter ( filter ) ; } }
Sets the scan criteria .
35,492
private List < HBaseDataWrapper > scanResults ( final String tableName , List < HBaseDataWrapper > results ) throws IOException { if ( fetchSize == null ) { for ( Result result : scanner ) { HBaseDataWrapper data = new HBaseDataWrapper ( tableName , result . getRow ( ) ) ; data . setColumns ( result . listCells ( ) ) ;...
Scan results .
35,493
public List < HBaseDataWrapper > loadAll ( final Table hTable , final List < Object > rows , final String columnFamily , final String [ ] columns ) throws IOException { setTableName ( hTable ) ; List < HBaseDataWrapper > results = new ArrayList < HBaseDataWrapper > ( ) ; List < Get > getRequest = new ArrayList < Get > ...
Load all .
35,494
public boolean hasNext ( ) { if ( scanner == null ) { return false ; } else { if ( fetchSize != null ) { if ( counter < fetchSize ) { return resultsIter . hasNext ( ) ; } } else { return resultsIter . hasNext ( ) ; } } return false ; }
Checks for next .
35,495
public static boolean isInvertedIndexingApplicable ( EntityMetadata m , boolean useSecondryIndex ) { boolean invertedIndexingApplicable = useSecondryIndex && CassandraPropertyReader . csmd . isInvertedIndexingEnabled ( m . getSchema ( ) ) && m . getType ( ) . isSuperColumnFamilyMetadata ( ) && ! m . isCounterColumnType...
Checks whether Inverted indexing is applicable for a given entity whose metadata is passed as parameter
35,496
private void alterColumn ( AlterTableOptions alterTableOptions , Schema schema , ColumnInfo columnInfo , AtomicBoolean updated ) { if ( ! KuduDBDataHandler . hasColumn ( schema , columnInfo . getColumnName ( ) ) ) { alterTableOptions . addNullableColumn ( columnInfo . getColumnName ( ) , KuduDBValidationClassMapper . g...
Alter column .
35,497
private void createKuduTable ( TableInfo tableInfo ) { List < ColumnSchema > columns = new ArrayList < ColumnSchema > ( ) ; if ( tableInfo . getTableIdType ( ) . isAnnotationPresent ( Embeddable . class ) ) { MetamodelImpl metaModel = ( MetamodelImpl ) kunderaMetadata . getApplicationMetadata ( ) . getMetamodel ( puMet...
Creates the kudu table .
35,498
private Object onAutoGenerator ( EntityMetadata m , Client < ? > client , Object e ) { Object autogenerator = getAutoGenClazz ( client ) ; if ( autogenerator instanceof AutoGenerator ) { Object generatedId = ( ( AutoGenerator ) autogenerator ) . generate ( client , m . getIdAttribute ( ) . getJavaType ( ) . getSimpleNa...
Generate Id when given auto generation strategy .
35,499
private Object onSequenceGenerator ( EntityMetadata m , Client < ? > client , IdDiscriptor keyValue , Object e ) { Object seqgenerator = getAutoGenClazz ( client ) ; if ( seqgenerator instanceof SequenceGenerator ) { Object generatedId = ( ( SequenceGenerator ) seqgenerator ) . generate ( keyValue . getSequenceDiscript...
Generate Id when given sequence generation strategy .