use of org.eclipse.persistence.sdo.SDODataObject in project eclipselink by eclipse-ee4j.
the class SDOTestCase method assertSequencesCopiedAndSwappedAfterFirstModifyOperation.
protected void assertSequencesCopiedAndSwappedAfterFirstModifyOperation(DataObject aRootObject, Sequence aCurrentSequenceAfterLoggingFirstOnParam) {
// verify logging is on
assertTrue(aRootObject.getChangeSummary().isLogging());
assertNotNull(aCurrentSequenceAfterLoggingFirstOnParam);
Sequence anOriginalSequenceAfterOperation = (Sequence) ((SDOChangeSummary) aRootObject.getChangeSummary()).getOriginalSequences().get(aRootObject);
Sequence aCurrentSequenceAfterOperation = ((SDODataObject) aRootObject).getSequence();
assertNotNull(anOriginalSequenceAfterOperation);
assertNotNull(aCurrentSequenceAfterOperation);
assertTrue(anOriginalSequenceAfterOperation == aCurrentSequenceAfterLoggingFirstOnParam);
}
use of org.eclipse.persistence.sdo.SDODataObject in project eclipselink by eclipse-ee4j.
the class JAXBList method add.
@Override
public void add(int index, Object element) {
Object container = getContainer();
if (container instanceof List) {
List list = (List) container;
if (!property.getType().isDataType()) {
JAXBHelperContext jaxbHelperContext = jaxbValueStore.getJAXBHelperContext();
Object unwrappedElement = jaxbHelperContext.unwrap((DataObject) element);
jaxbHelperContext.putWrapperDataObject(unwrappedElement, (SDODataObject) element);
list.add(index, unwrappedElement);
} else {
list.add(index, element);
}
} else {
throw new UnsupportedOperationException();
}
}
use of org.eclipse.persistence.sdo.SDODataObject in project eclipselink by eclipse-ee4j.
the class XPathHelper method processComplexQuery.
/**
* Evaluate the query represented by the XPath Expression fragment against
* the DataObject. A complex query contains logical operators.
*
* @param dataObject
* @param reference
* @param bracketContents
* @return
*/
private Object processComplexQuery(DataObject dataObject, String reference, String bracketContents) {
// convert the expression to postfix notation
OPStack opStack = new OPStack();
List expressionParts = opStack.processExpression(bracketContents);
ArrayList queryParts = new ArrayList();
// position of any 'and' / 'or'
for (int i = 0; i < expressionParts.size(); i++) {
Token tok = (Token) expressionParts.get(i);
if (tok.getName().equals(AND_STR) || tok.getName().equals(OR_STR)) {
queryParts.add(tok.getName());
} else {
// assume next three entries make up a query part
String propertyName = ((Token) expressionParts.get(i)).getName();
String queryValue = ((Token) expressionParts.get(++i)).getName();
int operator = getOperandFromString(((Token) expressionParts.get(++i)).getName());
queryParts.add(new QueryPart(propertyName.trim(), queryValue, operator));
}
}
// get the DataObject(s) to execute the query against
Property prop = dataObject.getInstanceProperty(reference);
List objects;
if (prop.isMany()) {
objects = dataObject.getList(prop);
} else {
objects = new ArrayList();
DataObject obj = dataObject.getDataObject(prop);
if (obj != null) {
objects.add(obj);
}
}
List valuesToReturn = new ArrayList();
Iterator iterObjects = objects.iterator();
while (iterObjects.hasNext()) {
SDODataObject cur = (SDODataObject) iterObjects.next();
// this iteration, evaluate each QueryPart against the current DataObject
ArrayList booleanValues = new ArrayList();
for (int j = 0; j < queryParts.size(); j++) {
if (queryParts.get(j).equals(AND_STR) || queryParts.get(j).equals(OR_STR)) {
// add 'and'/'or' keeping in correct order
booleanValues.add(queryParts.get(j));
} else {
// assume QueryPart - evaluate and add the result
QueryPart qp = (QueryPart) queryParts.get(j);
booleanValues.add(qp.evaluate(cur));
}
}
// single result is achieved
for (int k = 0; k < booleanValues.size(); k++) {
if (booleanValues.get(k).equals(AND_STR) || booleanValues.get(k).equals(OR_STR)) {
if (k >= 2) {
Boolean b1 = (Boolean) booleanValues.get(k - 1);
Boolean b2 = (Boolean) booleanValues.get(k - 2);
int logicalOp = getOperandFromString((String) booleanValues.get(k));
booleanValues.remove(k);
booleanValues.remove(k - 1);
booleanValues.set(k - 2, evaluate(b1, b2, logicalOp));
k = 0;
}
}
}
// if there isn't a single result something went wrong...
if (booleanValues.size() == 1) {
if ((Boolean) booleanValues.get(0)) {
valuesToReturn.add(cur);
}
}
}
return valuesToReturn;
}
use of org.eclipse.persistence.sdo.SDODataObject in project eclipselink by eclipse-ee4j.
the class SDOEqualityHelperTest method testDeepEqualWithSetNullComplexChild.
// TODO: process non-containment side of bidirectionals see #5853175
public void testDeepEqualWithSetNullComplexChild() {
// clear complex child
root.set("rootproperty2-notdatatype", null);
SDODataObject copyOfRoot = (SDODataObject) copyHelper.copy(root);
assertFalse(root.isSet("rootproperty2-notdatatype"));
assertNotNull(copyOfRoot);
// this assertion previously failed before fix for #5852525
assertTrue(equalityHelper.equal(root, copyOfRoot));
}
use of org.eclipse.persistence.sdo.SDODataObject in project eclipselink by eclipse-ee4j.
the class UserSetContextMapTestCases method testResolveWithHelperContextSetInUserMap.
/**
* Test should serialize/deserialize successfully/
*/
public void testResolveWithHelperContextSetInUserMap() {
// First overwrite the existing context with an empty one
SDOHelperContext.putHelperContext(Thread.currentThread().getContextClassLoader(), new SDOHelperContext());
String xsdString = getXSDString(CONTEXT1_DATAOBJECT_XSD_PATH);
localCtx = new SDOHelperContext("customId");
localCtx.getXSDHelper().define(xsdString);
localDObj = load(CONTEXT1_DATAOBJECT_XML_PATH, localCtx);
SDOHelperContext.putHelperContext(Thread.currentThread().getContextClassLoader(), localCtx);
serialize(localDObj, FILE_NAME);
SDODataObject dobj = (SDODataObject) deserialize(FILE_NAME);
String dobjImplClassName = dobj.getType().getInstanceClassName();
assertTrue("Expected [" + implClassname + "] but was [" + dobjImplClassName + "]", dobjImplClassName.equals(implClassname));
SDOHelperContext.removeHelperContext(Thread.currentThread().getContextClassLoader());
}
Aggregations