summaryrefslogtreecommitdiffstats
path: root/sandbox/kgoodson/mappingFramework/sdo-snapshot/src/main/java/com/agfa/hap/sdo/mapper/PartialDataObjectMapper.java
diff options
context:
space:
mode:
Diffstat (limited to 'sandbox/kgoodson/mappingFramework/sdo-snapshot/src/main/java/com/agfa/hap/sdo/mapper/PartialDataObjectMapper.java')
-rw-r--r--sandbox/kgoodson/mappingFramework/sdo-snapshot/src/main/java/com/agfa/hap/sdo/mapper/PartialDataObjectMapper.java97
1 files changed, 97 insertions, 0 deletions
diff --git a/sandbox/kgoodson/mappingFramework/sdo-snapshot/src/main/java/com/agfa/hap/sdo/mapper/PartialDataObjectMapper.java b/sandbox/kgoodson/mappingFramework/sdo-snapshot/src/main/java/com/agfa/hap/sdo/mapper/PartialDataObjectMapper.java
new file mode 100644
index 0000000000..ce4d446629
--- /dev/null
+++ b/sandbox/kgoodson/mappingFramework/sdo-snapshot/src/main/java/com/agfa/hap/sdo/mapper/PartialDataObjectMapper.java
@@ -0,0 +1,97 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package com.agfa.hap.sdo.mapper;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import sun.reflect.generics.reflectiveObjects.NotImplementedException;
+
+import com.agfa.hap.sdo.DataMapper;
+import com.agfa.hap.sdo.PartialDataFactory;
+import com.agfa.hap.sdo.PartialDataObject;
+import com.agfa.hap.sdo.Property;
+import com.agfa.hap.sdo.SnapshotDefinition;
+import com.agfa.hap.sdo.Type;
+
+/**
+ * Default implementation that only support object that are instances
+ * of {@link PartialDataObject}.
+ * @author AMOCZ
+ */
+public class PartialDataObjectMapper implements DataMapper<PartialDataObject> {
+
+ @SuppressWarnings("unchecked")
+ public Iterator<PartialDataObject> getObjects(PartialDataObject object, Property property) {
+ return object.getList(property).iterator();
+ }
+
+ public Object getProperty(PartialDataObject object, Property property) {
+ return object.get(property);
+ }
+
+ public Type getType(PartialDataObject object) {
+ return object.getType();
+ }
+
+ public Type getCorrespondingType(Class clazz) {
+ throw new IllegalArgumentException("No sdo type for class " + clazz.getName());
+ }
+
+ public void setProperty(PartialDataObject object, Property property, Object value) {
+ if (property.isMany()) {
+ if (property.getOpposite() != null) {
+ ((PartialDataObject) value).set(property.getOpposite(), object);
+ } else {
+ object.getList(property).add(value);
+ }
+ } else {
+ object.set(property, value);
+ }
+ }
+
+ public void setUnavailable(PartialDataObject object, Property property) {
+ object.setUnavailable(property);
+ }
+
+ public PartialDataObject create(Type type) {
+ return PartialDataFactory.INSTANCE.create(type);
+ }
+
+ public PartialDataObject newProxy(Type type, Object identity) {
+ return PartialDataFactory.INSTANCE.createProxy(type, identity);
+ }
+
+ public boolean isProxy(PartialDataObject object) {
+ return object.isProxy();
+ }
+
+ public Collection<PartialDataObject> getProperties(Collection<PartialDataObject> object, Property bulkProperty, SnapshotDefinition def) {
+ throw new NotImplementedException();
+ }
+
+ public boolean isBulkProperty(Class clazz, Property property) {
+ return false;
+ }
+
+
+
+}