Search in sources :

Example 11 with StoreManager

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);
}
Also used : StoreManager(org.datanucleus.store.StoreManager)

Example 12 with StoreManager

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);
}
Also used : StoreManager(org.datanucleus.store.StoreManager)

Example 13 with StoreManager

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());
    }
}
Also used : Query(org.datanucleus.store.query.Query) ClassLoaderResolver(org.datanucleus.ClassLoaderResolver) NucleusException(org.datanucleus.exceptions.NucleusException) AbstractClassMetaData(org.datanucleus.metadata.AbstractClassMetaData) StoreManager(org.datanucleus.store.StoreManager)

Aggregations

StoreManager (org.datanucleus.store.StoreManager)13 NucleusUserException (org.datanucleus.exceptions.NucleusUserException)4 NucleusException (org.datanucleus.exceptions.NucleusException)3 SchemaAwareStoreManager (org.datanucleus.store.schema.SchemaAwareStoreManager)3 HashSet (java.util.HashSet)2 Map (java.util.Map)2 ClassLoaderResolver (org.datanucleus.ClassLoaderResolver)2 FileMetaData (org.datanucleus.metadata.FileMetaData)2 MetaDataManager (org.datanucleus.metadata.MetaDataManager)2 SchemaTool (org.datanucleus.store.schema.SchemaTool)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 HashMap (java.util.HashMap)1 Properties (java.util.Properties)1 StringTokenizer (java.util.StringTokenizer)1 JDOMetadata (javax.jdo.metadata.JDOMetadata)1 PersistenceNucleusContext (org.datanucleus.PersistenceNucleusContext)1 StoreNucleusContext (org.datanucleus.StoreNucleusContext)1 JDOPersistenceManagerFactory (org.datanucleus.api.jdo.JDOPersistenceManagerFactory)1 TransactionIsolationNotSupportedException (org.datanucleus.exceptions.TransactionIsolationNotSupportedException)1 AbstractClassMetaData (org.datanucleus.metadata.AbstractClassMetaData)1