use of org.eclipse.persistence.oxm.sequenced.Setting in project eclipselink by eclipse-ee4j.
the class SDOSequence method convertToSetting.
private Setting convertToSetting(XPathFragment xPathFragment, NamespaceResolver nsResolver) {
Setting setting = new Setting();
String name = xPathFragment.getLocalName();
if (null == name) {
name = xPathFragment.getShortName();
}
setting.setName(name);
if (xPathFragment.hasNamespace()) {
setting.setNamespaceURI(nsResolver.resolveNamespacePrefix(xPathFragment.getPrefix()));
}
return setting;
}
use of org.eclipse.persistence.oxm.sequenced.Setting in project eclipselink by eclipse-ee4j.
the class SDOSequence method convertToSetting.
private Setting convertToSetting(Property property, Object value) {
SDOProperty sdoProperty = (SDOProperty) property;
DatabaseMapping mapping = sdoProperty.getXmlMapping();
Setting setting = new Setting();
SDOType sdoType = dataObject.getType();
XMLDescriptor xmlDescriptor = sdoType.getXmlDescriptor();
if (null == mapping) {
setting.setObject(dataObject);
mapping = xmlDescriptor.getMappingForAttributeName("openContentProperties");
setting.setMapping(mapping);
XMLRoot xmlRoot = new XMLRoot();
if (value instanceof XMLRoot) {
xmlRoot.setLocalName(((XMLRoot) value).getLocalName());
xmlRoot.setNamespaceURI(((XMLRoot) value).getNamespaceURI());
xmlRoot.setObject(((XMLRoot) value).getObject());
} else {
xmlRoot.setLocalName(sdoProperty.getName());
xmlRoot.setNamespaceURI(sdoProperty.getUri());
xmlRoot.setObject(value);
// do not set schema type for global properties
SDOTypeHelper hlpr = (SDOTypeHelper) dataObject.getType().getHelperContext().getTypeHelper();
if (hlpr.getOpenContentProperty(sdoProperty.getUri(), sdoProperty.getName()) == null) {
QName schemaTypeQName = hlpr.getXSDTypeFromSDOType(property.getType());
if (schemaTypeQName != null && schemaTypeQName != XMLConstants.STRING_QNAME) {
xmlRoot.setSchemaType(schemaTypeQName);
}
}
}
setting.setValue(xmlRoot, false);
} else {
setting = convertToSetting(mapping, value);
}
return setting;
}
use of org.eclipse.persistence.oxm.sequenced.Setting in project eclipselink by eclipse-ee4j.
the class SDOSequence method convertToSetting.
private Setting convertToSetting(DatabaseMapping mapping, Object value) {
XMLDescriptor xmlDescriptor = (XMLDescriptor) mapping.getDescriptor();
NamespaceResolver nsResolver = xmlDescriptor.getNamespaceResolver();
Setting rootSetting = new Setting();
XMLField xmlField = (XMLField) mapping.getField();
if (xmlField == null) {
if (mapping instanceof XMLObjectReferenceMapping) {
xmlField = (XMLField) ((XMLObjectReferenceMapping) mapping).getFields().get(0);
} else if (mapping instanceof XMLCollectionReferenceMapping) {
xmlField = (XMLField) ((XMLCollectionReferenceMapping) mapping).getFields().get(0);
}
}
Setting setting = rootSetting;
if (xmlField != null) {
XPathFragment xPathFragment = xmlField.getXPathFragment();
rootSetting = convertToSetting(xPathFragment, nsResolver);
setting = rootSetting;
while (xPathFragment.getNextFragment() != null) {
xPathFragment = xPathFragment.getNextFragment();
Setting childSetting = convertToSetting(xPathFragment, nsResolver);
setting.addChild(childSetting);
setting = childSetting;
}
}
setting.setObject(dataObject);
setting.setMapping(mapping);
setting.setValue(value, false);
return rootSetting;
}
use of org.eclipse.persistence.oxm.sequenced.Setting in project eclipselink by eclipse-ee4j.
the class SDOSequence method remove.
private void remove(Setting setting) {
CoreMapping mapping = setting.getMapping();
if (null != mapping) {
Property property = null;
if (null == setting.getName()) {
XMLRoot xmlRoot = (XMLRoot) setting.getValue();
if (null != xmlRoot) {
property = dataObject.getInstanceProperty(xmlRoot.getLocalName());
valuesToSettings.remove(new Key(property, setting.getValue()));
}
} else {
property = dataObject.getInstanceProperty(mapping.getAttributeName());
valuesToSettings.remove(new Key(property, setting.getValue()));
}
if (property.isMany()) {
ListWrapper listWrapper = (ListWrapper) dataObject.getList(property);
listWrapper.remove(setting.getValue(), false, false);
} else {
dataObject.unset(property, false, false);
}
} else if (setting.getName() != null && setting.getName().equals(TEXT_XPATH)) {
// Handle "text()"
dataObject._setModified(true);
}
List<Setting> children = setting.getChildren();
if (null != children) {
int childrenSize = children.size();
for (int x = 0; x < childrenSize; x++) {
remove(children.get(x));
}
}
}
use of org.eclipse.persistence.oxm.sequenced.Setting in project eclipselink by eclipse-ee4j.
the class SDOSequence method addSettingWithoutModifyingDataObject.
/**
* INTERNAL:
*/
public boolean addSettingWithoutModifyingDataObject(Property property, Object value, boolean checkAllowed) {
if (checkAllowed && !isAllowedInSequence(property)) {
return false;
}
Setting setting = convertToSetting(property, value);
valuesToSettings.put(new Key(property, value), setting);
settings.add(setting);
return true;
}
Aggregations