use of org.apache.cayenne.map.Procedure in project cayenne by apache.
the class NameBuilderTest method testName_ProcedureContext.
@Test
public void testName_ProcedureContext() {
Procedure procedure = new Procedure();
ProcedureParameter p0 = new ProcedureParameter();
p0.setName(NameBuilder.builder(p0).in(procedure).name());
assertEquals("UntitledProcedureParameter", p0.getName());
procedure.addCallParameter(p0);
ProcedureParameter p1 = new ProcedureParameter();
p1.setName(NameBuilder.builder(p1).in(procedure).name());
assertEquals("UntitledProcedureParameter1", p1.getName());
procedure.addCallParameter(p1);
}
use of org.apache.cayenne.map.Procedure in project cayenne by apache.
the class NameBuilderTest method testName_DataMapContext.
@Test
public void testName_DataMapContext() {
DataMap map = new DataMap();
map.setDefaultPackage("com.foo");
DbEntity de0 = new DbEntity();
de0.setName(NameBuilder.builder(de0).in(map).name());
assertEquals("db_entity", de0.getName());
map.addDbEntity(de0);
DbEntity de1 = new DbEntity();
de1.setName(NameBuilder.builder(de1).in(map).name());
assertEquals("db_entity1", de1.getName());
map.addDbEntity(de1);
ObjEntity oe0 = new ObjEntity();
oe0.setName(NameBuilder.builder(oe0).in(map).name());
assertEquals("ObjEntity", oe0.getName());
map.addObjEntity(oe0);
ObjEntity oe1 = new ObjEntity();
oe1.setName(NameBuilder.builder(oe1).in(map).name());
assertEquals("ObjEntity1", oe1.getName());
map.addObjEntity(oe1);
ObjEntity oe2 = new ObjEntity();
oe2.setName(NameBuilder.builder(oe0).in(map).baseName("db_entity").name());
assertEquals("Should not conflict with similarly named DbEntity", "Db_entity", oe2.getName());
map.addObjEntity(oe2);
Procedure p0 = new Procedure();
p0.setName(NameBuilder.builder(p0).in(map).name());
assertEquals("procedure", p0.getName());
map.addProcedure(p0);
Procedure p1 = new Procedure();
p1.setName(NameBuilder.builder(p1).in(map).name());
assertEquals("procedure1", p1.getName());
map.addProcedure(p1);
Procedure p2 = new Procedure();
p2.setName(NameBuilder.builder(p1).in(map).baseName("db_enity").name());
assertEquals("Should not conflict with similarly named DbEntity", "db_enity", p2.getName());
map.addProcedure(p2);
QueryDescriptor q0 = QueryDescriptor.selectQueryDescriptor();
q0.setName(NameBuilder.builder(q0).in(map).name());
assertEquals("query", q0.getName());
map.addQueryDescriptor(q0);
QueryDescriptor q1 = QueryDescriptor.ejbqlQueryDescriptor();
q1.setName(NameBuilder.builder(q1).in(map).name());
assertEquals("query1", q1.getName());
map.addQueryDescriptor(q1);
Embeddable e0 = new Embeddable();
e0.setClassName("com.foo." + NameBuilder.builder(e0).in(map).name());
assertEquals("com.foo.Embeddable", e0.getClassName());
map.addEmbeddable(e0);
Embeddable e1 = new Embeddable();
e1.setClassName("com.foo." + NameBuilder.builder(e1).in(map).name());
assertEquals("com.foo.Embeddable1", e1.getClassName());
map.addEmbeddable(e1);
}
use of org.apache.cayenne.map.Procedure in project cayenne by apache.
the class ProcedureQueryValidator method validateRoot.
void validateRoot(ProcedureQueryDescriptor query, ValidationResult validationResult) {
DataMap map = query.getDataMap();
Object root = query.getRoot();
if (root == null && map != null) {
addFailure(validationResult, query, "ProcedureQuery '%s' has no root", query.getName());
}
// procedure query only supports procedure root
if (root instanceof Procedure) {
Procedure procedure = (Procedure) root;
// procedure may have been deleted...
if (map != null && map.getProcedure(procedure.getName()) != procedure) {
addFailure(validationResult, query, "ProcedureQuery '%s' has invalid Procedure root: %s", query.getName(), procedure.getName());
}
return;
}
if (root instanceof String) {
if (map != null && map.getProcedure(root.toString()) == null) {
addFailure(validationResult, query, "ProcedureQuery '%s' has invalid Procedure root: %s", query.getName(), root);
}
}
}
use of org.apache.cayenne.map.Procedure in project cayenne by apache.
the class ProcedureHandler method addProcedure.
private void addProcedure(Attributes attributes) throws SAXException {
String name = attributes.getValue("name");
String returningValue = attributes.getValue("returningValue");
if (null == name) {
throw new SAXException("ProcedureHandler::addProcedure() - no procedure name.");
}
procedure = new Procedure(name);
procedure.setReturningValue(returningValue != null && returningValue.equalsIgnoreCase(DataMapHandler.TRUE));
procedure.setSchema(attributes.getValue("schema"));
procedure.setCatalog(attributes.getValue("catalog"));
map.addProcedure(procedure);
}
use of org.apache.cayenne.map.Procedure in project cayenne by apache.
the class DbLoadDataStore method addProcedureSafe.
void addProcedureSafe(Procedure procedure) {
Procedure old = getProcedure(procedure.getName());
if (old != null) {
removeProcedure(old.getName());
}
addProcedure(procedure);
}
Aggregations