Search in sources :

Example 16 with SienaRestrictedApiException

use of siena.SienaRestrictedApiException in project siena by mandubian.

the class SdbMappingUtils method getDomainName.

public static String getDomainName(Class<?> clazz, String prefix) {
    ClassInfo ci = ClassInfo.getClassInfo(clazz);
    if (ClassInfo.isAutoIncrement(ci.getIdField())) {
        throw new SienaRestrictedApiException("DB", "getItemName", "@Id AUTO_INCREMENT not supported by SDB");
    }
    String domain = prefix + ci.tableName;
    return domain;
}
Also used : SienaRestrictedApiException(siena.SienaRestrictedApiException) ClassInfo(siena.ClassInfo)

Example 17 with SienaRestrictedApiException

use of siena.SienaRestrictedApiException in project siena by mandubian.

the class GaeQueryUtils method buildJoinFieldKeysMap.

public static <T> Map<Field, ArrayList<Key>> buildJoinFieldKeysMap(QueryData<T> query) {
    List<QueryJoin> joins = query.getJoins();
    // join queries
    Map<Field, ArrayList<Key>> fieldMap = new HashMap<Field, ArrayList<Key>>();
    for (QueryJoin join : joins) {
        Field field = join.field;
        if (!ClassInfo.isModel(field.getType())) {
            throw new SienaRestrictedApiException(GaePersistenceManager.DB, "join", "Join not possible: Field " + field.getName() + " is not a relation field");
        } else if (join.sortFields != null && join.sortFields.length != 0)
            throw new SienaRestrictedApiException(GaePersistenceManager.DB, "join", "Join not allowed with sort fields");
        fieldMap.put(field, new ArrayList<Key>());
    }
    // join annotations
    for (Field field : ClassInfo.getClassInfo(query.getQueriedClass()).joinFields) {
        fieldMap.put(field, new ArrayList<Key>());
    }
    return fieldMap;
}
Also used : Field(java.lang.reflect.Field) HashMap(java.util.HashMap) SienaRestrictedApiException(siena.SienaRestrictedApiException) QueryJoin(siena.QueryJoin) ArrayList(java.util.ArrayList) Key(com.google.appengine.api.datastore.Key)

Example 18 with SienaRestrictedApiException

use of siena.SienaRestrictedApiException in project siena by mandubian.

the class BaseTestNoAutoInc_3_ITER method testIterLimitOffsetLongAutoID.

public void testIterLimitOffsetLongAutoID() {
    if (supportsAutoincrement()) {
        Iterable<PersonLongAutoID> people = pm.createQuery(PersonLongAutoID.class).order("n").iter(2, 1);
        assertNotNull(people);
        PersonLongAutoID[] array = new PersonLongAutoID[] { LongAutoID_CURIE, LongAutoID_EINSTEIN };
        int i = 0;
        for (PersonLongAutoID person : people) {
            assertEquals(array[i], person);
            i++;
        }
    } else {
        try {
            Iterable<PersonLongAutoID> people = pm.createQuery(PersonLongAutoID.class).order("n").iter(2, 1);
        } catch (SienaRestrictedApiException ex) {
            return;
        }
        fail();
    }
}
Also used : SienaRestrictedApiException(siena.SienaRestrictedApiException) PersonLongAutoID(siena.base.test.model.PersonLongAutoID)

Example 19 with SienaRestrictedApiException

use of siena.SienaRestrictedApiException in project siena by mandubian.

the class BaseTestNoAutoInc_1_CRUD method testSaveLongAutoID.

public void testSaveLongAutoID() {
    if (supportsAutoincrement()) {
        PersonLongAutoID maxwell = new PersonLongAutoID();
        maxwell.firstName = "James Clerk";
        maxwell.lastName = "Maxwell";
        maxwell.city = "Edinburgh";
        maxwell.n = 4;
        pm.save(maxwell);
        assertNotNull(maxwell.id);
        List<PersonLongAutoID> people = queryPersonLongAutoIDOrderBy("n", 0, false).fetch();
        assertEquals(4, people.size());
        assertEquals(LongAutoID_TESLA, people.get(0));
        assertEquals(LongAutoID_CURIE, people.get(1));
        assertEquals(LongAutoID_EINSTEIN, people.get(2));
        assertEquals(maxwell, people.get(3));
        maxwell.firstName = "James Clerk UPD";
        maxwell.lastName = "Maxwell UPD";
        maxwell.city = "Edinburgh UPD";
        maxwell.n = 5;
        pm.save(maxwell);
        assertNotNull(maxwell.id);
        people = queryPersonLongAutoIDOrderBy("n", 0, false).fetch();
        assertEquals(4, people.size());
        assertEquals(LongAutoID_TESLA, people.get(0));
        assertEquals(LongAutoID_CURIE, people.get(1));
        assertEquals(LongAutoID_EINSTEIN, people.get(2));
        assertEquals(maxwell, people.get(3));
    } else {
        try {
            PersonLongAutoID maxwell = new PersonLongAutoID();
            maxwell.firstName = "James Clerk";
            maxwell.lastName = "Maxwell";
            maxwell.city = "Edinburgh";
            maxwell.n = 4;
            pm.save(maxwell);
        } catch (SienaRestrictedApiException ex) {
            return;
        }
        fail();
    }
}
Also used : SienaRestrictedApiException(siena.SienaRestrictedApiException) PersonLongAutoID(siena.base.test.model.PersonLongAutoID)

Example 20 with SienaRestrictedApiException

use of siena.SienaRestrictedApiException in project siena by mandubian.

the class BaseTestNoAutoInc_2_FETCH method testFilterOperatorEqualLongAutoID.

public void testFilterOperatorEqualLongAutoID() {
    if (supportsAutoincrement()) {
        PersonLongAutoID person = pm.createQuery(PersonLongAutoID.class).filter("id", LongAutoID_EINSTEIN.id).get();
        assertNotNull(person);
        assertEquals(LongAutoID_EINSTEIN, person);
    } else {
        try {
            PersonLongAutoID person = pm.createQuery(PersonLongAutoID.class).filter("id", LongAutoID_EINSTEIN.id).get();
        } catch (SienaRestrictedApiException ex) {
            return;
        }
        fail();
    }
}
Also used : SienaRestrictedApiException(siena.SienaRestrictedApiException) PersonLongAutoID(siena.base.test.model.PersonLongAutoID)

Aggregations

SienaRestrictedApiException (siena.SienaRestrictedApiException)23 PersonLongAutoID (siena.base.test.model.PersonLongAutoID)11 SienaException (siena.SienaException)6 Id (siena.Id)5 Field (java.lang.reflect.Field)4 Entity (com.google.appengine.api.datastore.Entity)2 Date (java.util.Date)2 DateTime (siena.DateTime)2 Json (siena.Json)2 SimpleDate (siena.SimpleDate)2 Discovery4Search (siena.base.test.model.Discovery4Search)2 DecimalPrecision (siena.core.DecimalPrecision)2 Polymorphic (siena.core.Polymorphic)2 Embedded (siena.embed.Embedded)2 Key (com.google.appengine.api.datastore.Key)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1 StringReader (java.io.StringReader)1 BigDecimal (java.math.BigDecimal)1 SQLException (java.sql.SQLException)1