use of org.datanucleus.store.StoreManager in project datanucleus-core by datanucleus.
the class FederatedPersistenceHandler method insertObject.
/* (non-Javadoc)
* @see org.datanucleus.store.StorePersistenceHandler#insertObject(org.datanucleus.store.ObjectProvider)
*/
public void insertObject(ObjectProvider op) {
StoreManager classStoreMgr = storeMgr.getStoreManagerForClass(op.getClassMetaData());
classStoreMgr.getPersistenceHandler().insertObject(op);
}
use of org.datanucleus.store.StoreManager in project datanucleus-core by datanucleus.
the class FederatedPersistenceHandler method locateObjects.
/* (non-Javadoc)
* @see org.datanucleus.store.StorePersistenceHandler#locateObjects(org.datanucleus.store.ObjectProvider[])
*/
public void locateObjects(ObjectProvider[] ops) {
StoreManager classStoreMgr = storeMgr.getStoreManagerForClass(ops[0].getClassMetaData());
classStoreMgr.getPersistenceHandler().locateObjects(ops);
}
use of org.datanucleus.store.StoreManager in project datanucleus-core by datanucleus.
the class FederatedQueryManagerImpl method newQuery.
/**
* Method to generate a new query using the passed query as basis.
* @param language The query language
* @param ec ExecutionContext
* @param query The query filter (String) or a previous Query
* @return The Query
*/
public Query newQuery(String language, ExecutionContext ec, Object query) {
if (language == null) {
return null;
}
String languageImpl = language;
// Find the query support for this language and this datastore
if (query == null) {
// TODO We don't have candidate so don't know the StoreManager to use
throw new NucleusException("Not yet supported for queries with unknown candidate");
}
if (query instanceof String) {
// Single-string query
String queryString = (String) query;
String candidateName = null;
if (languageImpl.equalsIgnoreCase(Query.LANGUAGE_JDOQL) && queryString.toUpperCase().indexOf(" FROM ") > 0) {
int candidateStart = queryString.toUpperCase().indexOf(" FROM ") + 6;
int candidateEnd = queryString.indexOf(" ", candidateStart + 1);
candidateName = queryString.substring(candidateStart, candidateEnd);
}
if (candidateName != null) {
ClassLoaderResolver clr = nucleusCtx.getClassLoaderResolver(null);
AbstractClassMetaData cmd = nucleusCtx.getMetaDataManager().getMetaDataForClass(candidateName, clr);
StoreManager classStoreMgr = ((FederatedStoreManager) storeMgr).getStoreManagerForClass(cmd);
return classStoreMgr.newQuery(languageImpl, ec, (String) query);
}
// TODO Find StoreManager for the candidate
throw new NucleusException("Not yet supported for single-string queries");
} else if (query instanceof Query) {
// Based on previous query
StoreManager storeMgr = ((Query) query).getStoreManager();
return storeMgr.newQuery(languageImpl, ec, (Query) query);
} else {
throw new NucleusException("Not yet supported for queries taking in object of type " + query.getClass());
}
}
Aggregations