_id stringlengths 2 7 | title stringlengths 3 140 | partition stringclasses 3
values | text stringlengths 73 34.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q164200 | BlockchainImporter.getBlockWithTransactions | train | public Block getBlockWithTransactions(BigInteger blockNumber)
{
return EtherObjectConverterUtil.convertEtherBlockToKunderaBlock(client.getBlock(blockNumber, true));
} | java | {
"resource": ""
} |
q164201 | FilterImpl.ignoreScan | train | private boolean ignoreScan(String intf)
{
for (String ignored : ignoredPackages)
{
if (intf.startsWith(ignored + "."))
{
return true;
}
}
return false;
} | java | {
"resource": ""
} |
q164202 | QueryResolver.getQueryImplementation | train | public Query getQueryImplementation(String jpaQuery, PersistenceDelegator persistenceDelegator, Class mappedClass,
boolean isNative, final KunderaMetadata kunderaMetadata)
{
if (jpaQuery == null)
{
throw new QueryHandlerException("Query String should not be null ");
}
if (jpaQuery.trim().endsWith(Constants.SEMI_COLON))
{
throw new QueryHandlerException("unexpected char: ';' in query [ " + jpaQuery + " ]");
}
KunderaQuery kunderaQuery = null;
ApplicationMetadata appMetadata = kunderaMetadata.getApplicationMetadata();
String mappedQuery = appMetadata.getQuery(jpaQuery);
isNative = mappedQuery != null ? appMetadata.isNative(jpaQuery) : isNative;
EntityMetadata m = null;
// In case of named native query
if (!isNative)
{
kunderaQuery = new KunderaQuery(mappedQuery != null ? mappedQuery : jpaQuery, kunderaMetadata);
KunderaQueryParser parser = new KunderaQueryParser(kunderaQuery);
parser.parse();
kunderaQuery.postParsingInit();
m = kunderaQuery.getEntityMetadata();
}
else
{
// Means if it is a namedNativeQuery.
if (appMetadata.isNative(jpaQuery))
{
mappedClass = appMetadata.getMappedClass(jpaQuery);
}
kunderaQuery = new KunderaQuery(jpaQuery, kunderaMetadata);
kunderaQuery.isNativeQuery = true;
m = KunderaMetadataManager.getEntityMetadata(kunderaMetadata, mappedClass);
Field entityClazzField = null;
try
{
entityClazzField = kunderaQuery.getClass().getDeclaredField("entityClass");
if (entityClazzField != null && !entityClazzField.isAccessible())
{
entityClazzField.setAccessible(true);
}
entityClazzField.set(kunderaQuery, mappedClass);
}
catch (Exception e)
{
log.error(e.getMessage());
throw new QueryHandlerException(e);
}
}
Query query = null;
try
{
query = getQuery(jpaQuery, persistenceDelegator, m, kunderaQuery, kunderaMetadata);
}
catch (Exception e)
{
log.error(e.getMessage());
throw new QueryHandlerException(e);
}
return query;
} | java | {
"resource": ""
} |
q164203 | HBaseDataHandler.addColumnFamilyToTable | train | private void addColumnFamilyToTable(String tableName, String columnFamilyName) throws IOException
{
HColumnDescriptor cfDesciptor = new HColumnDescriptor(columnFamilyName);
try
{
if (admin.tableExists(tableName))
{
// Before any modification to table schema, it's necessary to
// disable it
if (!admin.isTableEnabled(tableName))
{
admin.enableTable(tableName);
}
HTableDescriptor descriptor = admin.getTableDescriptor(tableName.getBytes());
boolean found = false;
for (HColumnDescriptor hColumnDescriptor : descriptor.getColumnFamilies())
{
if (hColumnDescriptor.getNameAsString().equalsIgnoreCase(columnFamilyName))
found = true;
}
if (!found)
{
if (admin.isTableEnabled(tableName))
{
admin.disableTable(tableName);
}
admin.addColumn(tableName, cfDesciptor);
// Enable table once done
admin.enableTable(tableName);
}
}
else
{
log.warn("Table {} doesn't exist, so no question of adding column family {} to it!", tableName,
columnFamilyName);
}
}
catch (IOException e)
{
log.error("Error while adding column family {}, to table{} . ", columnFamilyName, tableName);
throw e;
}
} | java | {
"resource": ""
} |
q164204 | HBaseDataHandler.setHBaseDataIntoObject | train | private void setHBaseDataIntoObject(String columnName, byte[] columnValue, Map<String, Field> columnNameToFieldMap,
Object columnFamilyObj, boolean isEmbeddeble) throws PropertyAccessException
{
String qualifier = columnName.substring(columnName.indexOf("#") + 1, columnName.lastIndexOf("#"));
// Get Column from metadata
Field columnField = columnNameToFieldMap.get(qualifier);
if (columnField != null)
{
if (isEmbeddeble)
{
PropertyAccessorHelper.set(columnFamilyObj, columnField, columnValue);
}
else
{
columnFamilyObj = HBaseUtils.fromBytes(columnValue, columnFamilyObj.getClass());
}
}
} | java | {
"resource": ""
} |
q164205 | SparkClientFactory.configureClientProperties | train | private void configureClientProperties(PersistenceUnitMetadata puMetadata)
{
SparkSchemaMetadata metadata = SparkPropertyReader.ssmd;
ClientProperties cp = metadata != null ? metadata.getClientProperties() : null;
if (cp != null)
{
DataStore dataStore = metadata != null ? metadata.getDataStore(puMetadata.getProperty("kundera.client"))
: null;
List<Server> servers = dataStore != null && dataStore.getConnection() != null ? dataStore.getConnection()
.getServers() : null;
if (servers!=null && !servers.isEmpty())
{
Server server = servers.get(0);
sparkconf.set("hostname", server.getHost());
sparkconf.set("portname", server.getPort());
}
Connection conn = dataStore.getConnection();
Properties props = conn.getProperties();
Enumeration e = props.propertyNames();
while (e.hasMoreElements())
{
String key = (String) e.nextElement();
sparkconf.set(key, props.getProperty(key));
}
}
} | java | {
"resource": ""
} |
q164206 | HBaseDataWrapper.setColumns | train | public void setColumns(List<Cell> columns)
{
for (Cell column : columns)
{
putColumn(CellUtil.cloneFamily(column), CellUtil.cloneQualifier(column), CellUtil.cloneValue(column));
}
} | java | {
"resource": ""
} |
q164207 | HBaseDataWrapper.putColumn | train | private void putColumn(byte[] family, byte[] qualifier, byte[] qualifierValue)
{
this.columns.put(Bytes.toString(family) + ":" + Bytes.toString(qualifier), qualifierValue);
} | java | {
"resource": ""
} |
q164208 | GraphBuilder.buildNode | train | public final Node buildNode(Object entity, PersistenceDelegator pd, Object entityId, NodeState nodeState)
{
String nodeId = ObjectGraphUtils.getNodeId(entityId, entity.getClass());
Node node = this.graph.getNode(nodeId);
// If this node is already there in graph (may happen for bidirectional
// relationship, do nothing and return null)
// return node in case has already been traversed.
if (node != null)
{
if (this.generator.traversedNodes.contains(node))
{
return node;
}
return null;
}
node = new NodeBuilder().assignState(nodeState).buildNode(entity, pd, entityId, nodeId).node;
this.graph.addNode(node.getNodeId(), node);
return node;
} | java | {
"resource": ""
} |
q164209 | GraphBuilder.getRelationBuilder | train | RelationBuilder getRelationBuilder(Object target, Relation relation, Node source)
{
RelationBuilder relationBuilder = new RelationBuilder(target, relation, source);
relationBuilder.assignGraphGenerator(this.generator);
return relationBuilder;
} | java | {
"resource": ""
} |
q164210 | HBaseClient.findData | train | public <E> List<E> findData(EntityMetadata m, Object rowKey, byte[] startRow, byte[] endRow,
List<Map<String, Object>> columnsToOutput, Filter filters)
{
String tableName = HBaseUtils.getHTableName(m.getSchema(), m.getTableName());
FilterList filterList = getFilterList(filters);
try
{
return handler.readData(tableName, m, rowKey, startRow, endRow, columnsToOutput, filterList);
}
catch (IOException ioex)
{
log.error("Error during find by range, Caused by: .", ioex);
throw new KunderaException("Error during find by range, Caused by: .", ioex);
}
} | java | {
"resource": ""
} |
q164211 | HBaseClient.getFilterList | train | private FilterList getFilterList(Filter filters)
{
FilterList filterList = null;
if (filters != null)
{
if (FilterList.class.isAssignableFrom(filters.getClass()))
{
filterList = (FilterList) filters;
}
else
{
filterList = new FilterList();
filterList.addFilter(filters);
}
}
return filterList;
} | java | {
"resource": ""
} |
q164212 | QueryImpl.addToRelationStack | train | protected void addToRelationStack(Map<Object, Object> relationStack, Object entity, EntityMetadata m)
{
Object obj = entity;
if (entity instanceof EnhanceEntity)
{
obj = ((EnhanceEntity) entity).getEntity();
}
relationStack.put(obj.getClass().getCanonicalName() + "#" + PropertyAccessorHelper.getId(obj, m), obj);
} | java | {
"resource": ""
} |
q164213 | QueryImpl.populateEmbeddedIdUsingLucene | train | private List<Object> populateEmbeddedIdUsingLucene(EntityMetadata m, Client client, List<Object> result,
Map<String, Object> searchFilter, MetamodelImpl metaModel)
{
List<Object> compositeIds = new ArrayList<Object>();
for (String compositeIdName : searchFilter.keySet())
{
Object compositeId = null;
Map<String, String> uniquePKs = (Map<String, String>) searchFilter.get(compositeIdName);
compositeId = KunderaCoreUtils.initialize(m.getIdAttribute().getBindableJavaType(), compositeId);
prepareCompositeIdObject(m.getIdAttribute(), compositeId, uniquePKs, metaModel);
compositeIds.add(compositeId);
}
return findUsingLucene(m, client, compositeIds.toArray());
} | java | {
"resource": ""
} |
q164214 | QueryImpl.prepareCompositeIdObject | train | private Object prepareCompositeIdObject(final SingularAttribute attribute, Object compositeId,
Map<String, String> uniquePKs, MetamodelImpl metaModel)
{
Field[] fields = attribute.getBindableJavaType().getDeclaredFields();
EmbeddableType embeddable = metaModel.embeddable(attribute.getBindableJavaType());
for (Field field : attribute.getBindableJavaType().getDeclaredFields())
{
if (!ReflectUtils.isTransientOrStatic(field))
{
if (metaModel.isEmbeddable(((AbstractAttribute) embeddable.getAttribute(field.getName()))
.getBindableJavaType()))
{
try
{
field.setAccessible(true);
Object embeddedObject = prepareCompositeIdObject(
(SingularAttribute) embeddable.getAttribute(field.getName()),
KunderaCoreUtils.initialize(((AbstractAttribute) embeddable.getAttribute(field
.getName())).getBindableJavaType(), field.get(compositeId)), uniquePKs,
metaModel);
PropertyAccessorHelper.set(compositeId, field, embeddedObject);
}
catch (IllegalAccessException e)
{
log.error(e.getMessage());
}
}
else
{
PropertyAccessorHelper.set(
compositeId,
field,
PropertyAccessorHelper.fromSourceToTargetClass(field.getType(), String.class,
uniquePKs.get(field.getName())));
}
}
}
return compositeId;
} | java | {
"resource": ""
} |
q164215 | QueryImpl.findUsingLucene | train | private List<Object> findUsingLucene(EntityMetadata m, Client client, Object[] primaryKeys)
{
String idField = m.getIdAttribute().getName();
String equals = "=";
MetamodelImpl metaModel = (MetamodelImpl) kunderaMetadata.getApplicationMetadata().getMetamodel(
m.getPersistenceUnit());
EntityType entityType = metaModel.entity(m.getEntityClazz());
String columnName = ((AbstractAttribute) entityType.getAttribute(idField)).getJPAColumnName();
List<Object> result = new ArrayList<Object>();
Queue queue = getKunderaQuery().getFilterClauseQueue();
KunderaQuery kunderaQuery = getKunderaQuery();
for (Object primaryKey : primaryKeys)
{
FilterClause filterClause = kunderaQuery.new FilterClause(columnName, equals, primaryKey, idField);
kunderaQuery.setFilter(kunderaQuery.getEntityAlias() + "." + columnName + " = " + primaryKey);
queue.clear();
queue.add(filterClause);
List<Object> object = findUsingLucene(m, client);
if (object != null && !object.isEmpty())
result.add(object.get(0));
}
return result;
} | java | {
"resource": ""
} |
q164216 | QueryImpl.populateUsingLucene | train | protected List<Object> populateUsingLucene(EntityMetadata m, Client client, List<Object> result,
String[] columnsToSelect)
{
Set<Object> uniquePKs = null;
MetamodelImpl metaModel = (MetamodelImpl) kunderaMetadata.getApplicationMetadata().getMetamodel(
m.getPersistenceUnit());
if (client.getIndexManager().getIndexer().getClass().getName().equals(IndexingConstants.LUCENE_INDEXER))
{
String luceneQ = KunderaCoreUtils.getLuceneQueryFromJPAQuery(kunderaQuery, kunderaMetadata);
Map<String, Object> searchFilter = client.getIndexManager().search(m.getEntityClazz(), luceneQ,
Constants.INVALID, Constants.INVALID);
// Map<String, Object> searchFilter =
// client.getIndexManager().search(kunderaMetadata, kunderaQuery,
// persistenceDelegeator, m);
boolean isEmbeddedId = metaModel.isEmbeddable(m.getIdAttribute().getBindableJavaType());
if (isEmbeddedId)
{
return populateEmbeddedIdUsingLucene(m, client, result, searchFilter, metaModel);
}
Object[] primaryKeys = searchFilter.values().toArray(new Object[] {});
// Object[] primaryKeys =
// ((List)searchFilter.get("primaryKeys")).toArray(new Object[] {});
uniquePKs = new HashSet<Object>(Arrays.asList(primaryKeys));
return findUsingLucene(m, client, uniquePKs.toArray());
}
else
{
return populateUsingElasticSearch(client, m);
}
} | java | {
"resource": ""
} |
q164217 | QueryImpl.populateUsingElasticSearch | train | private List populateUsingElasticSearch(Client client, EntityMetadata m)
{
Map<String, Object> searchFilter = client.getIndexManager().search(kunderaMetadata, kunderaQuery,
persistenceDelegeator, m, this.firstResult, this.maxResult);
Object[] primaryKeys = ((Map<String, Object>) searchFilter.get(Constants.PRIMARY_KEYS)).values().toArray(
new Object[] {});
Map<String, Object> aggregations = (Map<String, Object>) searchFilter.get(Constants.AGGREGATIONS);
Iterable<Expression> resultOrderIterable = (Iterable<Expression>) searchFilter
.get(Constants.SELECT_EXPRESSION_ORDER);
List<Object> results = new ArrayList<Object>();
if (!kunderaQuery.isAggregated())
{
results.addAll(findUsingLucene(m, client, primaryKeys));
}
else
{
if (KunderaQueryUtils.hasGroupBy(kunderaQuery.getJpqlExpression()))
{
populateGroupByResponse(aggregations, resultOrderIterable, results, client, m);
}
else
{
Iterator<Expression> resultOrder = resultOrderIterable.iterator();
while (resultOrder.hasNext())
{
Expression expression = (Expression) resultOrder.next();
if (AggregateFunction.class.isAssignableFrom(expression.getClass()))
{
if (aggregations.get(expression.toParsedText()) != null)
{
results.add(aggregations.get(expression.toParsedText()));
}
}
else
{
results.addAll(findUsingLucene(m, client, new Object[] { primaryKeys[0] }));
}
}
}
}
return results;
} | java | {
"resource": ""
} |
q164218 | QueryImpl.populateGroupByResponse | train | private void populateGroupByResponse(Map<String, Object> aggregations, Iterable<Expression> resultOrderIterable,
List<Object> results, Client client, EntityMetadata m)
{
List temp;
Object entity = null;
for (String entry : aggregations.keySet())
{
entity = null;
Object obj = aggregations.get(entry);
temp = new ArrayList<>();
Iterator<Expression> resultOrder = resultOrderIterable.iterator();
while (resultOrder.hasNext())
{
Expression expression = (Expression) resultOrder.next();
if (AggregateFunction.class.isAssignableFrom(expression.getClass()))
{
if (((Map) obj).get(expression.toParsedText()) != null)
{
temp.add(((Map) obj).get(expression.toParsedText()));
}
}
else
{
if (entity == null)
{
entity = findUsingLucene(m, client, new Object[] { entry }).get(0);
}
temp.add(getEntityFieldValue(m, entity, expression.toParsedText()));
}
}
results.add(temp.size() == 1 ? temp.get(0) : temp);
}
} | java | {
"resource": ""
} |
q164219 | QueryImpl.getEntityFieldValue | train | private Object getEntityFieldValue(EntityMetadata entityMetadata, Object entity, String field)
{
Class clazz = entityMetadata.getEntityClazz();
MetamodelImpl metaModel = (MetamodelImpl) kunderaMetadata.getApplicationMetadata().getMetamodel(
entityMetadata.getPersistenceUnit());
EntityType entityType = metaModel.entity(clazz);
if (field.indexOf(".") > 0 && entityMetadata.getEntityClazz().equals(entity.getClass()))
{
String fieldName = field.substring(field.indexOf(".") + 1, field.length());
Attribute attribute = entityType.getAttribute(fieldName);
return PropertyAccessorHelper.getObject(entity, (Field) attribute.getJavaMember());
}
else
{
// for hbase v2 client (sends arraylist for specific fields)
if (entity instanceof ArrayList)
{
Object element = ((ArrayList) entity).get(0);
((ArrayList) entity).remove(0);
return element;
}
else
{
return entity;
}
}
} | java | {
"resource": ""
} |
q164220 | QueryImpl.onUpdateDeleteEvent | train | protected int onUpdateDeleteEvent()
{
if (kunderaQuery.isDeleteUpdate())
{
List result = fetch();
onDeleteOrUpdate(result);
return result != null ? result.size() : 0;
}
return 0;
} | java | {
"resource": ""
} |
q164221 | QueryImpl.onDeleteOrUpdate | train | protected void onDeleteOrUpdate(List results)
{
if (results != null)
{
if (!kunderaQuery.isUpdateClause())
{
// then case of delete
for (Object result : results)
{
PersistenceCacheManager.addEntityToPersistenceCache(result, persistenceDelegeator,
PropertyAccessorHelper.getId(result, this.getEntityMetadata()));
persistenceDelegeator.remove(result);
}
}
else
{
EntityMetadata entityMetadata = getEntityMetadata();
for (Object result : results)
{
PersistenceCacheManager.addEntityToPersistenceCache(result, persistenceDelegeator,
PropertyAccessorHelper.getId(result, this.getEntityMetadata()));
for (UpdateClause c : kunderaQuery.getUpdateClauseQueue())
{
String columnName = c.getProperty();
try
{
DefaultEntityType entityType = (DefaultEntityType) kunderaMetadata.getApplicationMetadata()
.getMetamodel(entityMetadata.getPersistenceUnit())
.entity(entityMetadata.getEntityClazz());
// That will always be attribute name.
Attribute attribute = entityType.getAttribute(columnName);
// TODO : catch column name.
if (c.getValue() instanceof String)
{
PropertyAccessorHelper.set(result, (Field) attribute.getJavaMember(), c.getValue()
.toString());
}
else
{
PropertyAccessorHelper.set(result, (Field) attribute.getJavaMember(), c.getValue());
}
persistenceDelegeator.merge(result);
}
catch (IllegalArgumentException iax)
{
log.error("Invalid column name: " + columnName + " for class : "
+ entityMetadata.getEntityClazz());
throw new QueryHandlerException("Error while executing query: " + iax);
}
}
}
}
}
} | java | {
"resource": ""
} |
q164222 | QueryImpl.getParameterByName | train | private Parameter getParameterByName(String name)
{
if (getParameters() != null)
{
for (Parameter p : parameters)
{
if (name.equals(p.getName()))
{
return p;
}
}
}
return null;
} | java | {
"resource": ""
} |
q164223 | QueryImpl.getParameterByOrdinal | train | private Parameter getParameterByOrdinal(Integer position)
{
for (Parameter p : parameters)
{
if (position.equals(p.getPosition()))
{
return p;
}
}
return null;
} | java | {
"resource": ""
} |
q164224 | QueryImpl.onParameterValue | train | private List<Object> onParameterValue(String paramString)
{
List<Object> value = kunderaQuery.getClauseValue(paramString);
if (value == null)
{
throw new IllegalStateException("parameter has not been bound" + paramString);
}
return value;
} | java | {
"resource": ""
} |
q164225 | QueryImpl.handlePostEvent | train | protected void handlePostEvent()
{
EntityMetadata metadata = getEntityMetadata();
if (!kunderaQuery.isDeleteUpdate())
{
persistenceDelegeator.getEventDispatcher().fireEventListeners(metadata, null, PostLoad.class);
}
} | java | {
"resource": ""
} |
q164226 | QueryImpl.fetch | train | protected List fetch()
{
EntityMetadata metadata = getEntityMetadata();
Client client = persistenceDelegeator.getClient(metadata);
List results = isRelational(metadata) ? recursivelyPopulateEntities(metadata, client) : populateEntities(
metadata, client);
return results;
} | java | {
"resource": ""
} |
q164227 | QueryImpl.onValidateSingleResult | train | protected void onValidateSingleResult(List results)
{
if (results == null || results.isEmpty())
{
log.error("No result found for {} ", kunderaQuery.getJPAQuery());
throw new NoResultException("No result found!");
}
if (results.size() > 1)
{
log.error("Non unique results found for query {} ", kunderaQuery.getJPAQuery());
throw new NonUniqueResultException("Containing more than one result!");
}
} | java | {
"resource": ""
} |
q164228 | QueryImpl.assignReferenceToProxy | train | private void assignReferenceToProxy(List results)
{
if (results != null)
{
for (Object obj : results)
{
kunderaMetadata.getCoreMetadata().getLazyInitializerFactory().setProxyOwners(getEntityMetadata(), obj);
}
}
} | java | {
"resource": ""
} |
q164229 | KunderaPropertyBuilder.populatePersistenceUnitProperties | train | public static Map<String, String> populatePersistenceUnitProperties(PropertyReader reader)
{
String dbType = reader.getProperty(EthConstants.DATABASE_TYPE);
String host = reader.getProperty(EthConstants.DATABASE_HOST);
String port = reader.getProperty(EthConstants.DATABASE_PORT);
String dbName = reader.getProperty(EthConstants.DATABASE_NAME);
propertyNullCheck(dbType, host, port, dbName);
String username = reader.getProperty(EthConstants.DATABASE_USERNAME);
String pswd = reader.getProperty(EthConstants.DATABASE_PASSWORD);
Map<String, String> props = new HashMap<>();
props.put(EthConstants.KUNDERA_CLIENT_LOOKUP_CLASS, getKunderaClientToLookupClass(dbType));
props.put(EthConstants.KUNDERA_NODES, host);
props.put(EthConstants.KUNDERA_PORT, port);
props.put(EthConstants.KUNDERA_KEYSPACE, dbName);
props.put(EthConstants.KUNDERA_DIALECT, dbType);
if (username != null && !username.isEmpty() && pswd != null)
{
props.put(EthConstants.KUNDERA_USERNAME, username);
props.put(EthConstants.KUNDERA_PASSWORD, pswd);
}
if (dbType.equalsIgnoreCase(CASSANDRA))
{
props.put(CQL_VERSION, _3_0_0);
}
boolean schemaAutoGen = Boolean.parseBoolean(reader.getProperty(EthConstants.SCHEMA_AUTO_GENERATE));
boolean schemaDropExisting = Boolean.parseBoolean(reader.getProperty(EthConstants.SCHEMA_DROP_EXISTING));
if (schemaAutoGen)
{
if (schemaDropExisting)
{
props.put(EthConstants.KUNDERA_DDL_AUTO_PREPARE, "create");
}
else
{
props.put(EthConstants.KUNDERA_DDL_AUTO_PREPARE, "update");
}
}
LOGGER.info("Kundera properties : " + props);
return props;
} | java | {
"resource": ""
} |
q164230 | KunderaPropertyBuilder.propertyNullCheck | train | private static void propertyNullCheck(String dbType, String host, String port, String dbName)
{
if (dbType == null || dbType.isEmpty())
{
LOGGER.error("Property '" + EthConstants.DATABASE_TYPE + "' can't be null or empty");
throw new KunderaException("Property '" + EthConstants.DATABASE_TYPE + "' can't be null or empty");
}
if (host == null || host.isEmpty())
{
LOGGER.error("Property '" + EthConstants.DATABASE_HOST + "' can't be null or empty");
throw new KunderaException("Property '" + EthConstants.DATABASE_HOST + "' can't be null or empty");
}
if (port == null || port.isEmpty())
{
LOGGER.error("Property '" + EthConstants.DATABASE_PORT + "' can't be null or empty");
throw new KunderaException("Property '" + EthConstants.DATABASE_PORT + "' can't be null or empty");
}
if (dbName == null || dbName.isEmpty())
{
LOGGER.error("Property'" + EthConstants.DATABASE_NAME + "' can't be null or empty");
throw new KunderaException("Property '" + EthConstants.DATABASE_NAME + "' can't be null or empty");
}
} | java | {
"resource": ""
} |
q164231 | KunderaPropertyBuilder.getKunderaClientToLookupClass | train | private static String getKunderaClientToLookupClass(String client)
{
Datasource datasource;
try
{
datasource = Datasource.valueOf(client.toUpperCase());
}
catch (IllegalArgumentException ex)
{
LOGGER.error(client + " is not supported!", ex);
throw new KunderaException(client + " is not supported!", ex);
}
return clientNameToFactoryMap.get(datasource);
} | java | {
"resource": ""
} |
q164232 | PropertyAccessorHelper.set | train | public static void set(Object target, Field field, Object value)
{
if (target != null)
{
if (!field.isAccessible())
{
field.setAccessible(true);
}
try
{
field.set(target, value);
}
catch (IllegalArgumentException iarg)
{
throw new PropertyAccessException(iarg);
}
catch (IllegalAccessException iacc)
{
throw new PropertyAccessException(iacc);
}
} // ignore if object is null;
} | java | {
"resource": ""
} |
q164233 | PropertyAccessorHelper.getObject | train | public static Object getObject(Object from, Field field)
{
if (!field.isAccessible())
{
field.setAccessible(true);
}
try
{
return field.get(from);
}
catch (IllegalArgumentException iarg)
{
throw new PropertyAccessException(iarg);
}
catch (IllegalAccessException iacc)
{
throw new PropertyAccessException(iacc);
}
} | java | {
"resource": ""
} |
q164234 | PropertyAccessorHelper.getObjectCopy | train | public static Object getObjectCopy(Object from, Field field)
{
if (!field.isAccessible())
{
field.setAccessible(true);
}
try
{
PropertyAccessor<?> accessor = PropertyAccessorFactory.getPropertyAccessor(field);
return accessor.getCopy(field.get(from));
}
catch (IllegalArgumentException iarg)
{
throw new PropertyAccessException(iarg);
}
catch (IllegalAccessException iacc)
{
throw new PropertyAccessException(iacc);
}
} | java | {
"resource": ""
} |
q164235 | PropertyAccessorHelper.get | train | public static byte[] get(Object from, Field field)
{
PropertyAccessor<?> accessor = PropertyAccessorFactory.getPropertyAccessor(field);
return accessor.toBytes(getObject(from, field));
} | java | {
"resource": ""
} |
q164236 | PropertyAccessorHelper.getObject | train | @SuppressWarnings("null")
// TODO: Too much code, improve this, possibly by breaking it
public static final Object getObject(Object obj, String fieldName)
{
Field embeddedField;
try
{
embeddedField = obj.getClass().getDeclaredField(fieldName);
if (embeddedField != null)
{
if (!embeddedField.isAccessible())
{
embeddedField.setAccessible(true);
}
Object embededObject = embeddedField.get(obj);
if (embededObject == null)
{
Class embeddedObjectClass = embeddedField.getType();
if (Collection.class.isAssignableFrom(embeddedObjectClass))
{
if (embeddedObjectClass.equals(List.class))
{
return new ArrayList();
}
else if (embeddedObjectClass.equals(Set.class))
{
return new HashSet();
}
}
else
{
embededObject = embeddedField.getType().newInstance();
embeddedField.set(obj, embededObject);
}
}
return embededObject;
}
else
{
throw new PropertyAccessException("Embedded object not found: " + fieldName);
}
}
catch (Exception e)
{
throw new PropertyAccessException(e);
}
} | java | {
"resource": ""
} |
q164237 | PropertyAccessorHelper.getDeclaredFields | train | public static Field[] getDeclaredFields(Field relationalField)
{
Field[] fields;
if (isCollection(relationalField.getType()))
{
fields = PropertyAccessorHelper.getGenericClass(relationalField).getDeclaredFields();
}
else
{
fields = relationalField.getType().getDeclaredFields();
}
return fields;
} | java | {
"resource": ""
} |
q164238 | PropertyAccessorHelper.toClass | train | private static Class<?> toClass(Type o)
{
if (o instanceof GenericArrayType)
{
Class clazz = Array.newInstance(toClass(((GenericArrayType) o).getGenericComponentType()), 0).getClass();
return clazz;
}
return (Class<?>) o;
} | java | {
"resource": ""
} |
q164239 | PropertyAccessorHelper.getTypedClass | train | private static Class<?> getTypedClass(java.lang.reflect.Type type)
{
if (type instanceof Class)
{
return ((Class) type);
}
else if (type instanceof ParameterizedType)
{
java.lang.reflect.Type rawParamterizedType = ((ParameterizedType) type).getRawType();
return getTypedClass(rawParamterizedType);
}
else if (type instanceof TypeVariable)
{
java.lang.reflect.Type upperBound = ((TypeVariable) type).getBounds()[0];
return getTypedClass(upperBound);
}
throw new IllegalArgumentException("Error while finding generic class for :" + type);
} | java | {
"resource": ""
} |
q164240 | IndexManager.remove | train | public final void remove(EntityMetadata metadata, Object entity, Object key)
{
if (indexer != null)
{
if (indexer.getClass().getName().equals(IndexingConstants.LUCENE_INDEXER))
{
((com.impetus.kundera.index.lucene.Indexer) indexer).unindex(metadata, key, kunderaMetadata, null);
}
else
{
indexer.unIndex(metadata.getEntityClazz(), entity, metadata, (MetamodelImpl) kunderaMetadata
.getApplicationMetadata().getMetamodel(metadata.getPersistenceUnit()));
}
}
} | java | {
"resource": ""
} |
q164241 | IndexManager.write | train | public final void write(EntityMetadata metadata, Object entity)
{
if (indexer != null)
{
MetamodelImpl metamodel = (MetamodelImpl) kunderaMetadata.getApplicationMetadata().getMetamodel(
metadata.getPersistenceUnit());
((com.impetus.kundera.index.lucene.Indexer) indexer).index(metadata, metamodel, entity);
}
} | java | {
"resource": ""
} |
q164242 | DeepEquals.compareOrdered | train | private static boolean compareOrdered(DualKey dualKey, LinkedList<DualKey> stack, Collection visited)
{
Collection col1 = (Collection) dualKey._key1;
Collection col2 = (Collection) dualKey._key2;
if (ProxyHelper.isProxyCollection(col1) || ProxyHelper.isProxyCollection(col2))
{
return false;
}
if (col1.size() != col2.size())
{
return false;
}
Iterator i1 = col1.iterator();
Iterator i2 = col2.iterator();
while (i1.hasNext())
{
DualKey dk = new DualKey(i1.next(), i2.next());
if (!visited.contains(dk))
{
stack.addFirst(dk);
}
}
return true;
} | java | {
"resource": ""
} |
q164243 | DeepEquals.compareUnordered | train | private static boolean compareUnordered(Collection col1, Collection col2, Set visited)
{
if (ProxyHelper.isProxyCollection(col1) || ProxyHelper.isProxyCollection(col2))
{
return false;
}
if (col1.size() != col2.size())
{
return false;
}
int h1 = deepHashCode(col1);
int h2 = deepHashCode(col2);
if (h1 != h2)
{ // Faster than deep equals compare (O(n^2) comparison
// can be skipped
// when not equal)
return false;
}
List copy = new ArrayList(col2);
for (Object element1 : col1)
{
int len = copy.size();
for (int i = 0; i < len; i++)
{ // recurse here (yes, that makes
// this a Stack-based implementation
// with
// partial recursion in the case of
// unordered Sets).
if (deepEquals(element1, copy.get(i), visited))
{
copy.remove(i); // Shrink 2nd Set
break;
}
}
if (len == copy.size())
{ // Nothing found, therefore Collections
// are not equivalent
return false;
}
}
return true;
} | java | {
"resource": ""
} |
q164244 | EntityManagerSession.lookup | train | @SuppressWarnings("unchecked")
protected <T> T lookup(Class<T> entityClass, Object id)
{
String key = cacheKey(entityClass, id);
LOG.debug("Reading from L1 >> " + key);
T o = (T) sessionCache.get(key);
// go to second-level cache
if (o == null)
{
LOG.debug("Reading from L2 >> " + key);
Cache c = (Cache) getL2Cache();
if (c != null)
{
o = (T) c.get(key);
if (o != null)
{
LOG.debug("Found item in second level cache!");
}
}
}
return o;
} | java | {
"resource": ""
} |
q164245 | EntityManagerSession.store | train | protected void store(Object id, Object entity)
{
store(id, entity, Boolean.TRUE);
} | java | {
"resource": ""
} |
q164246 | EntityManagerSession.store | train | protected void store(Object id, Object entity, boolean spillOverToL2)
{
String key = cacheKey(entity.getClass(), id);
LOG.debug("Writing to L1 >> " + key);
sessionCache.put(key, entity);
if (spillOverToL2)
{
LOG.debug("Writing to L2 >>" + key);
// save to second level cache
Cache c = (Cache) getL2Cache();
if (c != null)
{
c.put(key, entity);
}
}
} | java | {
"resource": ""
} |
q164247 | EntityManagerSession.remove | train | protected <T> void remove(Class<T> entityClass, Object id, boolean spillOverToL2)
{
String key = cacheKey(entityClass, id);
LOG.debug("Removing from L1 >> " + key);
Object o = sessionCache.remove(key);
if (spillOverToL2)
{
LOG.debug("Removing from L2 >> " + key);
Cache c = (Cache) getL2Cache();
if (c != null)
{
c.evict(entityClass, key);
}
}
} | java | {
"resource": ""
} |
q164248 | ClientBase.persist | train | public void persist(Node node)
{
Object entity = node.getData();
Object id = node.getEntityId();
EntityMetadata metadata = KunderaMetadataManager.getEntityMetadata(kunderaMetadata, node.getDataClass());
isUpdate = node.isUpdate();
List<RelationHolder> relationHolders = getRelationHolders(node);
onPersist(metadata, entity, id, relationHolders);
id = PropertyAccessorHelper.getId(entity, metadata);
node.setEntityId(id);
indexNode(node, metadata);
} | java | {
"resource": ""
} |
q164249 | RethinkDBQuery.buildEntityFromCursor | train | private void buildEntityFromCursor(Object entity, HashMap obj, EntityType entityType)
{
Iterator<Attribute> iter = entityType.getAttributes().iterator();
while (iter.hasNext())
{
Attribute attribute = iter.next();
Field field = (Field) attribute.getJavaMember();
if (field.isAnnotationPresent(Id.class))
{
PropertyAccessorHelper.set(entity, field, obj.get(ID));
}
else
{
PropertyAccessorHelper.set(entity, field, obj.get(((AbstractAttribute) attribute).getJPAColumnName()));
}
}
} | java | {
"resource": ""
} |
q164250 | RethinkDBQuery.buildFunction | train | public static ReqlFunction1 buildFunction(final String colName, final Object obj, final String identifier)
{
return new ReqlFunction1()
{
@Override
public Object apply(ReqlExpr row)
{
switch (identifier)
{
case "<":
return row.g(colName).lt(obj);
case "<=":
return row.g(colName).le(obj);
case ">":
return row.g(colName).gt(obj);
case ">=":
return row.g(colName).ge(obj);
case "=":
return row.g(colName).eq(obj);
default:
logger.error("Operation not supported");
throw new KunderaException("Operation not supported");
}
}
};
} | java | {
"resource": ""
} |
q164251 | NumericUtils.checkIfZero | train | public static final boolean checkIfZero(String value, Class valueClazz)
{
boolean returnValue=false;
if(value != null && NumberUtils.isNumber(value) && numberTypes.get(valueClazz) != null)
{
switch (numberTypes.get(valueClazz))
{
case INTEGER:
returnValue = Integer.parseInt(value) == (NumberUtils.INTEGER_ZERO);
break;
case FLOAT:
returnValue = Float.parseFloat(value) == (NumberUtils.FLOAT_ZERO);
break;
case LONG:
returnValue = Long.parseLong(value) == (NumberUtils.LONG_ZERO);
break;
case BIGDECIMAL:
// Note: cannot use 'equals' here - it would require both BigDecimals to have
// the same scale.
returnValue = (new BigDecimal(value)).compareTo(BigDecimal.ZERO) == 0;
break;
case BIGINTEGER:
returnValue = (new BigInteger(value)).equals(BigInteger.ZERO);
break;
case SHORT:
returnValue = (new Short(value)).shortValue() == NumberUtils.SHORT_ZERO.shortValue();
break;
}
}
return returnValue;
} | java | {
"resource": ""
} |
q164252 | DocumentObjectMapper.getDocumentFromObject | train | static Map<String, DBObject> getDocumentFromObject(Metamodel metaModel, Object obj, Set<Attribute> columns,
String tableName) throws PropertyAccessException
{
Map<String, DBObject> embeddedObjects = new HashMap<String, DBObject>();
// BasicDBObject dBObj = new BasicDBObject();
for (Attribute column : columns)
{
String collectionName = ((AbstractAttribute) column).getTableName() != null
? ((AbstractAttribute) column).getTableName() : tableName;
DBObject dbObject = embeddedObjects.get(collectionName);
if (dbObject == null)
{
dbObject = new BasicDBObject();
embeddedObjects.put(collectionName, dbObject);
}
if (((MetamodelImpl) metaModel).isEmbeddable(((AbstractAttribute) column).getBindableJavaType()))
{
DefaultMongoDBDataHandler handler = new DefaultMongoDBDataHandler();
// handler.onEmbeddable(column, obj, metaModel, dBObj,
// collectionName);
handler.onEmbeddable(column, obj, metaModel, dbObject, collectionName);
}
else
{
extractFieldValue(obj, dbObject, column);
}
}
return embeddedObjects;
} | java | {
"resource": ""
} |
q164253 | DocumentObjectMapper.getDocumentListFromCollection | train | static BasicDBObject[] getDocumentListFromCollection(Metamodel metaModel, Collection coll, Set<Attribute> columns,
String tableName) throws PropertyAccessException
{
BasicDBObject[] dBObjects = new BasicDBObject[coll.size()];
int count = 0;
for (Object o : coll)
{
dBObjects[count] = (BasicDBObject) getDocumentFromObject(metaModel, o, columns, tableName).values()
.toArray()[0];
count++;
}
return dBObjects;
} | java | {
"resource": ""
} |
q164254 | DocumentObjectMapper.extractFieldValue | train | static void extractFieldValue(Object entity, DBObject dbObj, Attribute column) throws PropertyAccessException
{
try
{
Object valueObject = PropertyAccessorHelper.getObject(entity, (Field) column.getJavaMember());
if (valueObject != null)
{
Class javaType = column.getJavaType();
switch (AttributeType.getType(javaType))
{
case MAP:
Map mapObj = (Map) valueObject;
// BasicDBObjectBuilder builder =
// BasicDBObjectBuilder.start(mapObj);
BasicDBObjectBuilder b = new BasicDBObjectBuilder();
Iterator i = mapObj.entrySet().iterator();
while (i.hasNext())
{
Map.Entry entry = (Map.Entry) i.next();
b.add(entry.getKey().toString(),
MongoDBUtils.populateValue(entry.getValue(), entry.getValue().getClass()));
}
dbObj.put(((AbstractAttribute) column).getJPAColumnName(), b.get());
break;
case SET:
case LIST:
Collection collection = (Collection) valueObject;
BasicDBList basicDBList = new BasicDBList();
for (Object o : collection)
{
basicDBList.add(o);
}
dbObj.put(((AbstractAttribute) column).getJPAColumnName(), basicDBList);
break;
case POINT:
Point p = (Point) valueObject;
double[] coordinate = new double[] { p.getX(), p.getY() };
dbObj.put(((AbstractAttribute) column).getJPAColumnName(), coordinate);
break;
case ENUM:
case PRIMITIVE:
dbObj.put(((AbstractAttribute) column).getJPAColumnName(),
MongoDBUtils.populateValue(valueObject, javaType));
break;
}
}
}
catch (PropertyAccessException paex)
{
log.error("Error while getting column {} value, caused by : .",
((AbstractAttribute) column).getJPAColumnName(), paex);
throw new PersistenceException(paex);
}
} | java | {
"resource": ""
} |
q164255 | DefaultCouchbaseDataHandler.iterateAndPopulateJsonObject | train | private JsonObject iterateAndPopulateJsonObject(Object entity, Iterator<Attribute> iterator, String tableName)
{
JsonObject obj = JsonObject.create();
while (iterator.hasNext())
{
Attribute attribute = iterator.next();
Field field = (Field) attribute.getJavaMember();
Object value = PropertyAccessorHelper.getObject(entity, field);
obj.put(((AbstractAttribute) attribute).getJPAColumnName(), value);
}
obj.put(CouchbaseConstants.KUNDERA_ENTITY, tableName);
return obj;
} | java | {
"resource": ""
} |
q164256 | ReflectUtils.hasInterface | train | public static boolean hasInterface(Class<?> has, Class<?> in)
{
if (has.equals(in))
{
return true;
}
boolean match = false;
for (Class<?> intrface : in.getInterfaces())
{
if (intrface.getInterfaces().length > 0)
{
match = hasInterface(has, intrface);
}
else
{
match = intrface.equals(has);
}
if (match)
{
return true;
}
}
return false;
} | java | {
"resource": ""
} |
q164257 | ReflectUtils.getTypeArguments | train | public static Type[] getTypeArguments(Field property)
{
Type type = property.getGenericType();
if (type instanceof ParameterizedType)
{
return ((ParameterizedType) type).getActualTypeArguments();
}
return null;
} | java | {
"resource": ""
} |
q164258 | ReflectUtils.hasSuperClass | train | public static boolean hasSuperClass(Class<?> has, Class<?> in)
{
if (in.equals(has))
{
return true;
}
boolean match = false;
// stop if the superclass is Object
if (in.getSuperclass() != null && in.getSuperclass().equals(Object.class))
{
return match;
}
match = in.getSuperclass() != null ? hasSuperClass(has, in.getSuperclass()): false;
return match;
} | java | {
"resource": ""
} |
q164259 | ReflectUtils.classForName | train | public static Class<?> classForName(String className, ClassLoader classLoader)
{
try
{
Class<?> c = null;
try
{
c = Class.forName(className, true, ReflectUtils.class.getClassLoader());
}
catch (ClassNotFoundException e)
{
try
{
c = Class.forName(className);
}
catch (ClassNotFoundException e1)
{
if (classLoader == null)
{
throw e1;
}
else
{
c = classLoader.loadClass(className);
}
}
}
return c;
}
catch (ClassNotFoundException e)
{
throw new KunderaException(e);
}
} | java | {
"resource": ""
} |
q164260 | ReflectUtils.stripEnhancerClass | train | public static Class<?> stripEnhancerClass(Class<?> c)
{
String className = c.getName();
// strip CGLIB from name
int enhancedIndex = className.indexOf("$$EnhancerByCGLIB");
if (enhancedIndex != -1)
{
className = className.substring(0, enhancedIndex);
}
if (className.equals(c.getName()))
{
return c;
}
else
{
c = classForName(className, c.getClassLoader());
}
return c;
} | java | {
"resource": ""
} |
q164261 | OracleNoSQLDataHandler.saveLOBFile | train | public void saveLOBFile(Key key, File lobFile)
{
try
{
FileInputStream fis = new FileInputStream(lobFile);
Version version = kvStore.putLOB(key, fis, client.getDurability(), client.getTimeout(),
client.getTimeUnit());
}
catch (FileNotFoundException e)
{
log.warn("Unable to find file " + lobFile + ". This is being omitted, Caused by:" + e + ".");
}
catch (IOException e)
{
log.warn("IOException while writing file " + lobFile + ". This is being omitted. Caused by:" + e + ".");
}
} | java | {
"resource": ""
} |
q164262 | ElementCollectionCacheManager.getElementCollectionCache | train | public Map<Object, Map<Object, String>> getElementCollectionCache()
{
if (this.elementCollectionCache == null)
{
this.elementCollectionCache = new HashMap<Object, Map<Object, String>>();
}
return this.elementCollectionCache;
} | java | {
"resource": ""
} |
q164263 | ElementCollectionCacheManager.addElementCollectionCacheMapping | train | public void addElementCollectionCacheMapping(Object rowKey, Object elementCollectionObject,
String elementCollObjectName)
{
Map embeddedObjectMap = new HashMap<Object, String>();
if (getElementCollectionCache().get(rowKey) == null)
{
embeddedObjectMap.put(elementCollectionObject, elementCollObjectName);
getElementCollectionCache().put(rowKey, embeddedObjectMap);
}
else
{
getElementCollectionCache().get(rowKey).put(elementCollectionObject, elementCollObjectName);
}
} | java | {
"resource": ""
} |
q164264 | ElementCollectionCacheManager.getElementCollectionObjectName | train | public String getElementCollectionObjectName(Object rowKey, Object elementCollectionObject)
{
if (getElementCollectionCache().isEmpty() || getElementCollectionCache().get(rowKey) == null)
{
log.debug("No element collection object map found in cache for Row key " + rowKey);
return null;
}
else
{
Map<Object, String> elementCollectionObjectMap = getElementCollectionCache().get(rowKey);
String elementCollectionObjectName = elementCollectionObjectMap.get(elementCollectionObject);
if (elementCollectionObjectName == null)
{
for (Object obj : elementCollectionObjectMap.keySet())
{
if (DeepEquals.deepEquals(elementCollectionObject, obj))
{
elementCollectionObjectName = elementCollectionObjectMap.get(obj);
break;
}
}
}
if (elementCollectionObjectName == null)
{
log.debug("No element collection object name found in cache for object:" + elementCollectionObject);
return null;
}
else
{
return elementCollectionObjectName;
}
}
} | java | {
"resource": ""
} |
q164265 | ElementCollectionCacheManager.getLastElementCollectionObjectCount | train | public int getLastElementCollectionObjectCount(Object rowKey)
{
if (getElementCollectionCache().get(rowKey) == null)
{
log.debug("No element collection object map found in cache for Row key " + rowKey);
return -1;
}
else
{
Map<Object, String> elementCollectionMap = getElementCollectionCache().get(rowKey);
Collection<String> elementCollectionObjectNames = elementCollectionMap.values();
int max = 0;
for (String s : elementCollectionObjectNames)
{
String elementCollectionCountStr = s.substring(s.indexOf(Constants.EMBEDDED_COLUMN_NAME_DELIMITER) + 1);
int elementCollectionCount = 0;
try
{
elementCollectionCount = Integer.parseInt(elementCollectionCountStr);
}
catch (NumberFormatException e)
{
log.error("Invalid element collection Object name " + s);
throw new CacheException("Invalid element collection Object name " + s,e);
}
if (elementCollectionCount > max)
{
max = elementCollectionCount;
}
}
return max;
}
} | java | {
"resource": ""
} |
q164266 | KunderaGridFS.find | train | public List<GridFSDBFile> find(final DBObject query, final DBObject sort, final int firstResult,
final int maxResult)
{
List<GridFSDBFile> files = new ArrayList<GridFSDBFile>();
DBCursor c = null;
try
{
c = getFilesCollection().find(query);
if (sort != null)
{
c.sort(sort);
}
c.skip(firstResult).limit(maxResult);
while (c.hasNext())
{
files.add(findOne(c.next()));
}
}
finally
{
if (c != null)
{
c.close();
}
}
return files;
} | java | {
"resource": ""
} |
q164267 | ClientResolver.getClientFactory | train | public static ClientFactory getClientFactory(String persistenceUnit, Map<String, Object> puProperties,final KunderaMetadata kunderaMetadata)
{
ClientFactory clientFactory = instantiateClientFactory(persistenceUnit, puProperties, kunderaMetadata);
clientFactories.put(persistenceUnit, clientFactory);
return clientFactory;
} | java | {
"resource": ""
} |
q164268 | ClientResolver.instantiateClientFactory | train | private static ClientFactory instantiateClientFactory(String persistenceUnit, Map<String, Object> puProperties,
final KunderaMetadata kunderaMetadata)
{
ClientFactory clientFactory = null;
logger.info("Initializing client factory for: " + persistenceUnit);
PersistenceUnitMetadata persistenceUnitMetadata = kunderaMetadata.getApplicationMetadata()
.getPersistenceUnitMetadata(persistenceUnit);
String kunderaClientFactory = puProperties != null ? (String) puProperties
.get(PersistenceProperties.KUNDERA_CLIENT_FACTORY) : null;
if (kunderaClientFactory == null)
{
kunderaClientFactory = persistenceUnitMetadata.getProperties().getProperty(
PersistenceProperties.KUNDERA_CLIENT_FACTORY);
}
if (kunderaClientFactory == null)
{
throw new ClientResolverException(
"<kundera.client.lookup.class> is missing from persistence.xml, please provide specific client factory. e.g., <property name=\"kundera.client.lookup.class\" value=\"com.impetus.client.cassandra.pelops.PelopsClientFactory\" />");
}
try
{
clientFactory = (ClientFactory) Class.forName(kunderaClientFactory).newInstance();
Method m = GenericClientFactory.class.getDeclaredMethod("setPersistenceUnit", String.class);
if (!m.isAccessible())
{
m.setAccessible(true);
}
m.invoke(clientFactory, persistenceUnit);
m = GenericClientFactory.class.getDeclaredMethod("setExternalProperties", Map.class);
if (!m.isAccessible())
{
m.setAccessible(true);
}
m.invoke(clientFactory, puProperties);
m = GenericClientFactory.class.getDeclaredMethod("setKunderaMetadata", KunderaMetadata.class);
if (!m.isAccessible())
{
m.setAccessible(true);
}
m.invoke(clientFactory, kunderaMetadata);
}
catch (InstantiationException e)
{
onError(e);
}
catch (IllegalAccessException e)
{
onError(e);
}
catch (ClassNotFoundException e)
{
onError(e);
}
catch (SecurityException e)
{
onError(e);
}
catch (NoSuchMethodException e)
{
onError(e);
}
catch (IllegalArgumentException e)
{
onError(e);
}
catch (InvocationTargetException e)
{
onError(e);
}
if (clientFactory == null)
{
logger.error("Client Factory Not Configured For Specified Client Type : ");
throw new ClientResolverException("Client Factory Not Configured For Specified Client Type.");
}
logger.info("Finishing factory initialization");
return clientFactory;
} | java | {
"resource": ""
} |
q164269 | MongoDBSchemaManager.isCappedCollection | train | protected boolean isCappedCollection(TableInfo tableInfo)
{
return MongoDBPropertyReader.msmd != null ? MongoDBPropertyReader.msmd.isCappedCollection(databaseName,
tableInfo.getTableName()) : false;
} | java | {
"resource": ""
} |
q164270 | PersistenceValidator.onValidateEmbeddable | train | private void onValidateEmbeddable(Object embeddedObject, EmbeddableType embeddedColumn)
{
if (embeddedObject instanceof Collection)
{
for (Object obj : (Collection) embeddedObject)
{
for (Object column : embeddedColumn.getAttributes())
{
Attribute columnAttribute = (Attribute) column;
Field f = (Field) columnAttribute.getJavaMember();
this.factory.validate(f, embeddedObject, new AttributeConstraintRule());
}
}
}
else
{
for (Object column : embeddedColumn.getAttributes())
{
Attribute columnAttribute = (Attribute) column;
Field f = (Field) ((Field) columnAttribute.getJavaMember());
this.factory.validate(f, embeddedObject, new AttributeConstraintRule());
}
}
} | java | {
"resource": ""
} |
q164271 | SparkDataClientFactory.getDataClient | train | public static SparkDataClient getDataClient(String clientName)
{
if (clientPool.get(clientName) != null)
{
return clientPool.get(clientName);
}
try
{
SparkDataClient dataClient = (SparkDataClient) KunderaCoreUtils.createNewInstance(Class
.forName(clientNameToClass.get(clientName)));
clientPool.put(clientName, dataClient);
return dataClient;
}
catch (Exception e)
{
logger.error(clientName
+ " client is invalid/not supported. Please check kundera.client in persistence properties.");
throw new KunderaException(clientName
+ " client is invalid/not supported. Please check kundera.client in persistence properties.");
}
} | java | {
"resource": ""
} |
q164272 | AttributeConstraintRule.validateSize | train | private boolean validateSize(Object validationObject, Annotation annotate)
{
if (checkNullObject(validationObject))
{
return true;
}
int objectSize = 0;
int minSize = ((Size) annotate).min();
int maxSize = ((Size) annotate).max();
if (validationObject != null)
{
if (String.class.isAssignableFrom(validationObject.getClass()))
{
objectSize = ((String) validationObject).length();
}
else if (Collection.class.isAssignableFrom(validationObject.getClass()))
{
objectSize = ((Collection) validationObject).size();
}
else if (Map.class.isAssignableFrom(validationObject.getClass()))
{
objectSize = ((Map) validationObject).size();
}
else if (ArrayList.class.isAssignableFrom(validationObject.getClass()))
{
objectSize = ((ArrayList) validationObject).size();
}
else
{
throwValidationException(((Size) annotate).message());
}
}
return objectSize <= maxSize && objectSize >= minSize;
} | java | {
"resource": ""
} |
q164273 | AttributeConstraintRule.validatePattern | train | private boolean validatePattern(Object validationObject, Annotation annotate)
{
if (checkNullObject(validationObject))
{
return true;
}
java.util.regex.Pattern pattern = java.util.regex.Pattern.compile(((Pattern) annotate).regexp(),
((Pattern) annotate).flags().length);
Matcher matcherPattern = pattern.matcher((String) validationObject);
if (!matcherPattern.matches())
{
throwValidationException(((Pattern) annotate).message());
}
return true;
} | java | {
"resource": ""
} |
q164274 | AttributeConstraintRule.validatePast | train | private boolean validatePast(Object validationObject, Annotation annotate)
{
if (checkNullObject(validationObject))
{
return true;
}
int res = 0;
if (validationObject.getClass().isAssignableFrom(java.util.Date.class))
{
Date today = new Date();
Date pastDate = (Date) validationObject;
res = pastDate.compareTo(today);
}
else if (validationObject.getClass().isAssignableFrom(java.util.Calendar.class))
{
Calendar cal = Calendar.getInstance();
Calendar pastDate = (Calendar) validationObject;
res = pastDate.compareTo(cal);
}
// else
// {
// ruleExceptionHandler(((Past) annotate).message());
// }
if (res >= 0)
{
throwValidationException(((Past) annotate).message());
}
return true;
} | java | {
"resource": ""
} |
q164275 | AttributeConstraintRule.validateFuture | train | private boolean validateFuture(Object validationObject, Annotation annotate)
{
if (checkNullObject(validationObject))
{
return true;
}
int res = 0;
if (validationObject.getClass().isAssignableFrom(java.util.Date.class))
{
Date today = new Date();
Date futureDate = (Date) validationObject;
res = futureDate.compareTo(today);
}
else if (validationObject.getClass().isAssignableFrom(java.util.Calendar.class))
{
Calendar cal = Calendar.getInstance();
Calendar futureDate = (Calendar) validationObject;
res = futureDate.compareTo(cal);
}
// else
// {
// //ruleExceptionHandler(((Future) annotate).message());
// throw new RuleValidationException(((Future)
// annotate).message());
// }
if (res <= 0)
{
throwValidationException(((Future) annotate).message());
}
return true;
} | java | {
"resource": ""
} |
q164276 | AttributeConstraintRule.validateNull | train | private boolean validateNull(Object validationObject, Annotation annotate)
{
if (checkNullObject(validationObject))
{
return true;
}
if (!validationObject.equals(null) || validationObject != null)
{
throwValidationException(((Null) annotate).message());
}
return true;
} | java | {
"resource": ""
} |
q164277 | AttributeConstraintRule.validateMinValue | train | private boolean validateMinValue(Object validationObject, Annotation annotate)
{
if (checkNullObject(validationObject))
{
return true;
}
Long minValue = ((Min) annotate).value();
if (checkvalidDigitTypes(validationObject.getClass()))
{
if ((NumberUtils.toLong(toString(validationObject))) < minValue)
{
throwValidationException(((Min) annotate).message());
}
}
return true;
} | java | {
"resource": ""
} |
q164278 | AttributeConstraintRule.validateMaxValue | train | private boolean validateMaxValue(Object validationObject, Annotation annotate)
{
if (checkNullObject(validationObject))
{
return true;
}
Long maxValue = ((Max) annotate).value();
if (checkvalidDigitTypes(validationObject.getClass()))
{
if ((NumberUtils.toLong(toString(validationObject))) > maxValue)
{
throwValidationException(((Max) annotate).message());
}
}
return true;
} | java | {
"resource": ""
} |
q164279 | AttributeConstraintRule.validateDigits | train | private boolean validateDigits(Object validationObject, Annotation annotate)
{
if (checkNullObject(validationObject))
{
return true;
}
if (checkvalidDigitTypes(validationObject.getClass()))
{
if (!NumberUtils.isDigits(toString(validationObject)))
{
throwValidationException(((Digits) annotate).message());
}
}
return true;
} | java | {
"resource": ""
} |
q164280 | AttributeConstraintRule.validateMinDecimal | train | private boolean validateMinDecimal(Object validationObject, Annotation annotate)
{
if (validationObject != null)
{
try
{
if (checkvalidDeciDigitTypes(validationObject.getClass()))
{
BigDecimal minValue = NumberUtils.createBigDecimal(((DecimalMin) annotate).value());
BigDecimal actualValue = NumberUtils.createBigDecimal(toString(validationObject));
int res = actualValue.compareTo(minValue);
if (res < 0)
{
throwValidationException(((DecimalMin) annotate).message());
}
}
}
catch (NumberFormatException nfe)
{
throw new RuleValidationException(nfe.getMessage());
}
}
return true;
} | java | {
"resource": ""
} |
q164281 | AttributeConstraintRule.validateMaxDecimal | train | private boolean validateMaxDecimal(Object validationObject, Annotation annotate)
{
if (validationObject != null)
{
try
{
if (checkvalidDeciDigitTypes(validationObject.getClass()))
{
BigDecimal maxValue = NumberUtils.createBigDecimal(((DecimalMax) annotate).value());
BigDecimal actualValue = NumberUtils.createBigDecimal(toString(validationObject));
int res = actualValue.compareTo(maxValue);
if (res > 0)
{
throwValidationException(((DecimalMax) annotate).message());
}
}
}
catch (NumberFormatException nfe)
{
throw new RuleValidationException(nfe.getMessage());
}
}
return true;
} | java | {
"resource": ""
} |
q164282 | DateAccessor.getDateByPattern | train | public static Date getDateByPattern(String date)
{
if (StringUtils.isNumeric(date))
{
return new Date(Long.parseLong(date));
}
for (String p : patterns)
{
try
{
DateFormat formatter = new SimpleDateFormat(p);
Date dt = formatter.parse(date);
return dt;
}
catch (IllegalArgumentException iae)
{
// Do nothing.
// move to next pattern.
}
catch (ParseException e)
{
// Do nothing.
// move to next pattern.
}
}
log.error("Required Date format is not supported!" + date);
throw new PropertyAccessException("Required Date format is not supported!" + date);
} | java | {
"resource": ""
} |
q164283 | DateAccessor.getFormattedObect | train | public static String getFormattedObect(String date)
{
return date != null ? getDateByPattern(date).toString() : null;
} | java | {
"resource": ""
} |
q164284 | EnhanceEntity.getRelations | train | public Map<String, Object> getRelations()
{
return relations != null ? Collections.unmodifiableMap(relations) : null;
} | java | {
"resource": ""
} |
q164285 | CassandraHostConfiguration.getFailoverPolicy | train | private HostFailoverPolicy getFailoverPolicy(String failoverOption)
{
if (failoverOption != null)
{
if (Constants.FAIL_FAST.equals(failoverOption))
{
return HostFailoverPolicy.FAIL_FAST;
}
else if (Constants.ON_FAIL_TRY_ALL_AVAILABLE.equals(failoverOption))
{
return HostFailoverPolicy.ON_FAIL_TRY_ALL_AVAILABLE;
}
else if (Constants.ON_FAIL_TRY_ONE_NEXT_AVAILABLE.equals(failoverOption))
{
return HostFailoverPolicy.ON_FAIL_TRY_ONE_NEXT_AVAILABLE;
}
else
{
logger.warn("Invalid failover policy {}, using default {} ", failoverOption,
HostFailoverPolicy.ON_FAIL_TRY_ALL_AVAILABLE.name());
return HostFailoverPolicy.ON_FAIL_TRY_ALL_AVAILABLE;
}
}
return HostFailoverPolicy.ON_FAIL_TRY_ALL_AVAILABLE;
} | java | {
"resource": ""
} |
q164286 | PelopsUtils.generatePoolName | train | public static String generatePoolName(String node, int port, String keyspace)
{
return node + ":" + port + ":" + keyspace;
} | java | {
"resource": ""
} |
q164287 | PelopsUtils.getAuthenticationRequest | train | public static SimpleConnectionAuthenticator getAuthenticationRequest(String userName, String password)
{
SimpleConnectionAuthenticator authenticator = null;
if (userName != null || password != null)
{
authenticator = new SimpleConnectionAuthenticator(userName, password);
}
return authenticator;
} | java | {
"resource": ""
} |
q164288 | ESIndexer.buildResultMap | train | 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;
} | java | {
"resource": ""
} |
q164289 | ESIndexer.getSearchResponse | train | 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;
} | java | {
"resource": ""
} |
q164290 | KunderaWeb3jClient.persistBlocksAndTransactions | train | 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();
} | java | {
"resource": ""
} |
q164291 | KunderaWeb3jClient.persistTransactions | train | 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);
}
} | java | {
"resource": ""
} |
q164292 | KunderaWeb3jClient.getFirstBlock | train | 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);
}
} | java | {
"resource": ""
} |
q164293 | KunderaWeb3jClient.saveBlocks | train | 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);
}
} | java | {
"resource": ""
} |
q164294 | KunderaWeb3jClient.initializeWeb3j | train | 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));
}
} | java | {
"resource": ""
} |
q164295 | KunderaWeb3jClient.initializeKunderaParams | train | 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...");
} | java | {
"resource": ""
} |
q164296 | PersistenceService.getEM | train | public static synchronized EntityManager getEM(EntityManagerFactory emf, final String propertiesPath,
final String clazzName)
{
/** The client properties. */
Map<?, Map<String, String>> clientProperties = new HashMap<>();
/** The entity configurations. */
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();
} | java | {
"resource": ""
} |
q164297 | PersistenceService.loadClientProperties | train | 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));
}
}
}
}
} | java | {
"resource": ""
} |
q164298 | Neo4JClientFactory.createPoolOrConnection | train | @Override
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();
// registerShutdownHook(graphDb);
}
}
if (graphDb == null)
{
graphDb = new GraphDatabaseFactory().newEmbeddedDatabase(datastoreFilePath);
// registerShutdownHook(graphDb);
}
return graphDb;
} | java | {
"resource": ""
} |
q164299 | EntityManagerImpl.persist | train | @Override
public final void persist(Object e)
{
checkClosed();
checkTransactionNeeded();
try
{
getPersistenceDelegator().persist(e);
}
catch (Exception ex)
{
// onRollBack.
doRollback();
throw new KunderaException(ex);
}
} | java | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.