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;
}
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;
}
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();
}
}
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();
}
}
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();
}
}
Aggregations