use of org.eclipse.persistence.eis.mappings.EISOneToManyMapping in project eclipselink by eclipse-ee4j.
the class IndirectionMapProject method getEmployeeDescriptor.
private EISDescriptor getEmployeeDescriptor() {
EISDescriptor descriptor = new EISDescriptor();
descriptor.setJavaClass(Employee.class);
descriptor.setDataTypeName("employee");
descriptor.setPrimaryKeyFieldName("first-name/text()");
EISDirectMapping firstNameMapping = new EISDirectMapping();
firstNameMapping.setAttributeName("firstName");
firstNameMapping.setXPath("first-name/text()");
descriptor.addMapping(firstNameMapping);
EISOneToManyMapping projectMapping = new EISOneToManyMapping();
projectMapping.setAttributeName("projects");
projectMapping.setReferenceClass(Project.class);
projectMapping.setForeignKeyGroupingElement("project");
projectMapping.setIsForeignKeyRelationship(true);
projectMapping.useMapClass(java.util.TreeMap.class, "getType");
XQueryInteraction projectInteraction = new XQueryInteraction();
projectInteraction.setFunctionName("read-projects");
projectInteraction.setProperty("fileName", "project.xml");
projectInteraction.setXQueryString("project[@id='#project-id/text()']");
projectInteraction.setOutputResultPath("result");
projectMapping.setSelectionCall(projectInteraction);
projectMapping.addForeignKeyFieldName("project-id/text()", "@id");
descriptor.addMapping(projectMapping);
// Insert
XQueryInteraction insertCall = new XQueryInteraction();
insertCall.setFunctionName("insert");
insertCall.setProperty("fileName", "employee.xml");
insertCall.setXQueryString("employee");
descriptor.getQueryManager().setInsertCall(insertCall);
// Read object
XQueryInteraction readObjectCall = new XQueryInteraction();
readObjectCall.setFunctionName("read");
readObjectCall.setProperty("fileName", "employee.xml");
readObjectCall.setXQueryString("employee[first-name='#first-name/text()']");
readObjectCall.setOutputResultPath("result");
descriptor.getQueryManager().setReadObjectCall(readObjectCall);
// Read all
XQueryInteraction readAllCall = new XQueryInteraction();
readAllCall.setFunctionName("read-all");
readAllCall.setProperty("fileName", "employee.xml");
readAllCall.setXQueryString("employee");
readAllCall.setOutputResultPath("result");
descriptor.getQueryManager().setReadAllCall(readAllCall);
// Delete
XQueryInteraction deleteCall = new XQueryInteraction();
deleteCall.setFunctionName("delete");
deleteCall.setProperty("fileName", "employee.xml");
deleteCall.setXQueryString("employee[first-name='#first-name/text()']");
descriptor.getQueryManager().setDeleteCall(deleteCall);
// Update
XQueryInteraction updateCall = new XQueryInteraction();
updateCall.setFunctionName("update");
updateCall.setProperty("fileName", "employee.xml");
updateCall.setXQueryString("employee[first-name='#first-name/text()']");
descriptor.getQueryManager().setUpdateCall(updateCall);
return descriptor;
}
use of org.eclipse.persistence.eis.mappings.EISOneToManyMapping in project eclipselink by eclipse-ee4j.
the class MapProject method getEmployeeDescriptor.
private EISDescriptor getEmployeeDescriptor() {
EISDescriptor descriptor = new EISDescriptor();
descriptor.setJavaClass(Employee.class);
descriptor.setDataTypeName("employee");
descriptor.setPrimaryKeyFieldName("first-name/text()");
EISDirectMapping firstNameMapping = new EISDirectMapping();
firstNameMapping.setAttributeName("firstName");
firstNameMapping.setXPath("first-name/text()");
descriptor.addMapping(firstNameMapping);
EISOneToManyMapping projectMapping = new EISOneToManyMapping();
projectMapping.setAttributeName("projects");
projectMapping.setReferenceClass(Project.class);
projectMapping.setForeignKeyGroupingElement("project");
projectMapping.setIsForeignKeyRelationship(true);
projectMapping.useMapClass(java.util.TreeMap.class, "getType");
projectMapping.dontUseIndirection();
XQueryInteraction projectInteraction = new XQueryInteraction();
projectInteraction.setFunctionName("read-projects");
projectInteraction.setProperty("fileName", "project.xml");
projectInteraction.setXQueryString("project[@id='#project-id/text()']");
projectInteraction.setOutputResultPath("result");
projectMapping.setSelectionCall(projectInteraction);
projectMapping.addForeignKeyFieldName("project-id/text()", "@id");
descriptor.addMapping(projectMapping);
// Insert
XQueryInteraction insertCall = new XQueryInteraction();
insertCall.setFunctionName("insert");
insertCall.setProperty("fileName", "employee.xml");
insertCall.setXQueryString("employee");
descriptor.getQueryManager().setInsertCall(insertCall);
// Read object
XQueryInteraction readObjectCall = new XQueryInteraction();
readObjectCall.setFunctionName("read");
readObjectCall.setProperty("fileName", "employee.xml");
readObjectCall.setXQueryString("employee[first-name='#first-name/text()']");
readObjectCall.setOutputResultPath("result");
descriptor.getQueryManager().setReadObjectCall(readObjectCall);
// Read all
XQueryInteraction readAllCall = new XQueryInteraction();
readAllCall.setFunctionName("read-all");
readAllCall.setProperty("fileName", "employee.xml");
readAllCall.setXQueryString("employee");
readAllCall.setOutputResultPath("result");
descriptor.getQueryManager().setReadAllCall(readAllCall);
// Delete
XQueryInteraction deleteCall = new XQueryInteraction();
deleteCall.setFunctionName("delete");
deleteCall.setProperty("fileName", "employee.xml");
deleteCall.setXQueryString("employee[first-name='#first-name/text()']");
descriptor.getQueryManager().setDeleteCall(deleteCall);
// Update
XQueryInteraction updateCall = new XQueryInteraction();
updateCall.setFunctionName("update");
updateCall.setProperty("fileName", "employee.xml");
updateCall.setXQueryString("employee[first-name='#first-name/text()']");
descriptor.getQueryManager().setUpdateCall(updateCall);
return descriptor;
}
use of org.eclipse.persistence.eis.mappings.EISOneToManyMapping in project eclipselink by eclipse-ee4j.
the class OwnedToExternalRootProject method getEmployeeDescriptor.
private EISDescriptor getEmployeeDescriptor() {
EISDescriptor descriptor = new EISDescriptor();
descriptor.setJavaClass(Employee.class);
descriptor.setDataTypeName("employee");
descriptor.descriptorIsAggregate();
EISDirectMapping firstNameMapping = new EISDirectMapping();
firstNameMapping.setAttributeName("firstName");
firstNameMapping.setXPath("first-name/text()");
descriptor.addMapping(firstNameMapping);
EISOneToManyMapping projectMapping = new EISOneToManyMapping();
projectMapping.setAttributeName("projects");
projectMapping.setReferenceClass(Project.class);
projectMapping.dontUseIndirection();
projectMapping.setIsForeignKeyRelationship(true);
XQueryInteraction projectInteraction = new XQueryInteraction();
projectInteraction.setFunctionName("read-projects");
projectInteraction.setProperty("fileName", "project.xml");
projectInteraction.setXQueryString("project[@id='#project-id/text()']");
projectInteraction.setOutputResultPath("result");
projectMapping.setSelectionCall(projectInteraction);
// projectMapping.addSourceForeignKeyFieldName("project-id", "@id");
projectMapping.addForeignKeyFieldName("project-id/text()", "@id");
// projectMapping.setSourceForeignKeyFieldName("project-id");
descriptor.addMapping(projectMapping);
return descriptor;
}
use of org.eclipse.persistence.eis.mappings.EISOneToManyMapping in project eclipselink by eclipse-ee4j.
the class RootToRootProject method getEmployeeDescriptor.
private EISDescriptor getEmployeeDescriptor() {
EISDescriptor descriptor = new EISDescriptor();
descriptor.setJavaClass(Employee.class);
descriptor.setDataTypeName("employee");
descriptor.setPrimaryKeyFieldName("first-name/text()");
EISDirectMapping firstNameMapping = new EISDirectMapping();
firstNameMapping.setAttributeName("firstName");
firstNameMapping.setXPath("first-name/text()");
descriptor.addMapping(firstNameMapping);
EISOneToManyMapping projectMapping = new EISOneToManyMapping();
projectMapping.setAttributeName("projects");
projectMapping.setReferenceClass(Project.class);
projectMapping.dontUseIndirection();
projectMapping.setIsForeignKeyRelationship(true);
XQueryInteraction projectInteraction = new XQueryInteraction();
projectInteraction.setFunctionName("read-projects");
projectInteraction.setProperty("fileName", "project.xml");
projectInteraction.setXQueryString("project[@id='#project-id/text()']");
projectInteraction.setOutputResultPath("result");
projectMapping.setSelectionCall(projectInteraction);
descriptor.getQueryManager().setReadAllQuery(new ReadAllQuery(projectInteraction));
projectMapping.addForeignKeyFieldName("project-id/text()", "@id");
descriptor.addMapping(projectMapping);
// Insert
XQueryInteraction insertCall = new XQueryInteraction();
insertCall.setFunctionName("insert");
insertCall.setProperty("fileName", "employee.xml");
insertCall.setXQueryString("employee");
descriptor.getQueryManager().setInsertCall(insertCall);
// Read object
XQueryInteraction readObjectCall = new XQueryInteraction();
readObjectCall.setFunctionName("read");
readObjectCall.setProperty("fileName", "employee.xml");
readObjectCall.setXQueryString("employee[first-name='#first-name/text()']");
readObjectCall.setOutputResultPath("result");
descriptor.getQueryManager().setReadObjectCall(readObjectCall);
// Read all
XQueryInteraction readAllCall = new XQueryInteraction();
readAllCall.setFunctionName("read-all");
readAllCall.setProperty("fileName", "employee.xml");
readAllCall.setXQueryString("employee");
readAllCall.setOutputResultPath("result");
descriptor.getQueryManager().setReadAllCall(readAllCall);
// Delete
XQueryInteraction deleteCall = new XQueryInteraction();
deleteCall.setFunctionName("delete");
deleteCall.setProperty("fileName", "employee.xml");
deleteCall.setXQueryString("employee[first-name='#first-name/text()']");
descriptor.getQueryManager().setDeleteCall(deleteCall);
// Update
XQueryInteraction updateCall = new XQueryInteraction();
updateCall.setFunctionName("update");
updateCall.setProperty("fileName", "employee.xml");
updateCall.setXQueryString("employee[first-name='#first-name/text()']");
descriptor.getQueryManager().setUpdateCall(updateCall);
return descriptor;
}
use of org.eclipse.persistence.eis.mappings.EISOneToManyMapping in project eclipselink by eclipse-ee4j.
the class OwnedToExternalRootProject method getEmployeeDescriptor.
private EISDescriptor getEmployeeDescriptor() {
EISDescriptor descriptor = new EISDescriptor();
descriptor.setJavaClass(Employee.class);
descriptor.descriptorIsAggregate();
descriptor.setDataTypeName("employee");
descriptor.setPrimaryKeyFieldName("first-name/text()");
EISDirectMapping firstNameMapping = new EISDirectMapping();
firstNameMapping.setAttributeName("firstName");
firstNameMapping.setXPath("first-name/text()");
descriptor.addMapping(firstNameMapping);
EISOneToManyMapping projectMapping = new EISOneToManyMapping();
projectMapping.setReferenceClass(Project.class);
projectMapping.setAttributeName("projects");
projectMapping.dontUseIndirection();
XQueryInteraction projectInteraction = new XQueryInteraction();
projectInteraction.setFunctionName("read-projects");
projectInteraction.setProperty("fileName", "project.xml");
projectInteraction.setXQueryString("project[leader/text()='#first-name/text()']");
projectInteraction.setOutputResultPath("result");
projectMapping.setSelectionCall(projectInteraction);
descriptor.addMapping(projectMapping);
return descriptor;
}
Aggregations