From 23d6118551e857da09afc0437aacd2b5ebb21297 Mon Sep 17 00:00:00 2001 From: Tuukka Lehtonen Date: Tue, 18 Aug 2020 10:58:28 +0300 Subject: [PATCH] Remove deprecated/duplicate version of org.simantics.objmap2 gitlab #139 --- org.simantics.objmap2/.classpath | 7 - org.simantics.objmap2/.project | 28 -- .../.settings/org.eclipse.jdt.core.prefs | 10 - org.simantics.objmap2/META-INF/MANIFEST.MF | 26 - org.simantics.objmap2/build.properties | 15 - org.simantics.objmap2/pom.xml | 17 - .../objmap/backward/IBackwardLinkType.java | 27 - .../objmap/backward/IBackwardMapping.java | 30 -- .../objmap/backward/IBackwardMappingRule.java | 29 -- .../backward/IBackwardMappingSchema.java | 22 - .../bidirectional/IBidirectionalLinkType.java | 21 - .../bidirectional/IBidirectionalMapping.java | 20 - .../IBidirectionalMappingRule.java | 20 - .../IBidirectionalMappingSchema.java | 24 - .../objmap/exceptions/MappingException.java | 35 -- .../objmap/forward/IForwardLinkType.java | 27 - .../objmap/forward/IForwardMapping.java | 23 - .../objmap/forward/IForwardMappingRule.java | 29 -- .../objmap/forward/IForwardMappingSchema.java | 22 - .../org/simantics/objmap/graph/IMapping.java | 142 ------ .../objmap/graph/IMappingListener.java | 30 -- .../org/simantics/objmap/graph/Mappings.java | 42 -- .../objmap/graph/annotations/Composition.java | 22 - .../annotations/CompoundRelatedGetValue.java | 30 -- .../annotations/CompoundRelatedSetValue.java | 24 - .../graph/annotations/DynamicGraphType.java | 23 - .../objmap/graph/annotations/GetType.java | 25 - .../objmap/graph/annotations/GraphType.java | 23 - .../graph/annotations/HasCollectionAdder.java | 24 - .../annotations/HasCollectionRemover.java | 24 - .../objmap/graph/annotations/HasSetter.java | 24 - .../annotations/OptionalRelatedElements.java | 29 -- .../graph/annotations/OrderedElementsAdd.java | 22 - .../graph/annotations/OrderedElementsGet.java | 31 -- .../graph/annotations/OrderedElementsRem.java | 23 - .../graph/annotations/OrderedSetType.java | 23 - .../graph/annotations/RelatedElement.java | 26 - .../graph/annotations/RelatedElements.java | 28 -- .../graph/annotations/RelatedElementsAdd.java | 23 - .../graph/annotations/RelatedElementsGet.java | 32 -- .../graph/annotations/RelatedElementsRem.java | 24 - .../graph/annotations/RelatedGetObj.java | 30 -- .../graph/annotations/RelatedGetValue.java | 33 -- .../RelatedOrderedSetElements.java | 27 - .../graph/annotations/RelatedSetObj.java | 24 - .../graph/annotations/RelatedSetValue.java | 24 - .../graph/annotations/RelatedValue.java | 36 -- .../objmap/graph/annotations/SetType.java | 25 - .../graph/annotations/UpdateMethod.java | 32 -- ...CompoundRelatedGetSetValueRuleFactory.java | 110 ---- .../annotations/factories/DataTypeUtils.java | 57 --- .../OptionalRelatedElementsRuleFactory.java | 44 -- .../factories/OrderedElementsRuleFactory.java | 55 -- .../factories/RelatedElementRuleFactory.java | 41 -- .../factories/RelatedElementsRuleFactory.java | 43 -- .../RelatedElementsRuleFactory2.java | 55 -- .../RelatedGetSetObjRuleFactory.java | 55 -- .../RelatedGetSetValueRuleFactory.java | 111 ---- .../RelatedOrderedSetElementsRuleFactory.java | 42 -- .../factories/RelatedValueRuleFactory.java | 60 --- .../factories/UpdateMethodFactory.java | 70 --- .../graph/annotations/meta/IsClassRule.java | 23 - .../annotations/meta/IsCollectionRule.java | 23 - .../graph/annotations/meta/IsFieldRule.java | 23 - .../graph/annotations/meta/IsGetSetRule.java | 24 - .../graph/annotations/meta/IsMethodRule.java | 23 - .../org/simantics/objmap/graph/impl/Link.java | 40 -- .../simantics/objmap/graph/impl/Mapping.java | 476 ------------------ .../objmap/graph/impl/RangeUpdateRequest.java | 77 --- .../objmap/graph/rules/MappedElementRule.java | 73 --- .../graph/rules/MappedElementsRule.java | 82 --- .../objmap/graph/rules/ValueRule.java | 69 --- .../graph/rules/adapters/IdentityAdapter.java | 34 -- .../graph/rules/adapters/ValueAdapter.java | 21 - .../rules/domain/CompoundValueAccessor.java | 152 ------ .../graph/rules/domain/IDomainAccessor.java | 26 - .../graph/rules/domain/MappingUtils.java | 92 ---- .../rules/domain/RelatedObjectAccessor.java | 71 --- .../rules/domain/RelatedObjectsAccessor.java | 63 --- .../RelatedOrderedSetElementsAccessor.java | 62 --- .../rules/domain/RelatedValueAccessor.java | 114 ----- .../rules/factory/IClassRuleFactory.java | 22 - .../rules/factory/ICollectionRuleFactory.java | 25 - .../rules/factory/IFieldRuleFactory.java | 23 - .../rules/factory/IGetSetRuleFactory.java | 24 - .../rules/factory/IMethodRuleFactory.java | 23 - .../rules/range/AdaptedRangeAccessor.java | 38 -- .../graph/rules/range/CollectionAccessor.java | 91 ---- .../range/CompoundGetSetValueAccessor.java | 84 ---- .../graph/rules/range/FieldAccessor.java | 76 --- .../rules/range/FieldAccessorWithDefault.java | 40 -- .../rules/range/GetSetObjectAccessor.java | 69 --- .../rules/range/GetSetValueAccessor.java | 84 ---- .../graph/rules/range/IRangeAccessor.java | 25 - .../graph/rules/range/ListAccessor.java | 94 ---- .../objmap/graph/schema/AdaptedLinkType.java | 87 ---- .../objmap/graph/schema/DefaultSchema.java | 98 ---- .../graph/schema/DynamicSimpleLinkType.java | 124 ----- .../objmap/graph/schema/ILinkType.java | 32 -- .../objmap/graph/schema/IMappingSchema.java | 31 -- .../objmap/graph/schema/MappingSchemas.java | 261 ---------- .../schema/OrderedSetSimpleLinkType.java | 34 -- .../objmap/graph/schema/SimpleLinkType.java | 140 ------ .../objmap/graph/schema/SimpleSchema.java | 94 ---- .../objmap/internal/BidirectionalLink.java | 30 -- .../objmap/internal/BidirectionalMapping.java | 140 ------ .../internal/MonotoneBackwardMapping.java | 63 --- .../internal/MonotoneForwardMapping.java | 58 --- .../objmap/structural/IStructuralObject.java | 49 -- .../objmap/structural/StructuralResource.java | 167 ------ .../StructuralRelatedElementsAdd.java | 23 - .../StructuralRelatedElementsGet.java | 32 -- .../StructuralRelatedElementsRem.java | 24 - .../annotations/StructuralRelatedGetObj.java | 30 -- .../annotations/StructuralRelatedSetObj.java | 24 - .../annotations/TypeRelatedElementsAdd.java | 23 - .../annotations/TypeRelatedElementsGet.java | 32 -- .../annotations/TypeRelatedElementsRem.java | 24 - .../annotations/TypeRelatedGetObj.java | 31 -- .../annotations/TypeRelatedGetValue.java | 34 -- .../annotations/TypeRelatedSetObj.java | 24 - .../annotations/TypeRelatedSetValue.java | 24 - .../annotations/factories/DataTypeUtils.java | 57 --- .../OptionalRelatedElementsRuleFactory.java | 44 -- .../factories/RelatedElementRuleFactory.java | 41 -- .../factories/RelatedElementsRuleFactory.java | 43 -- .../RelatedElementsRuleFactory2.java | 55 -- .../RelatedGetSetObjRuleFactory.java | 55 -- .../RelatedGetSetValueRuleFactory.java | 112 ----- .../RelatedOrderedSetElementsRuleFactory.java | 42 -- .../factories/RelatedValueRuleFactory.java | 61 --- ...StructuralRelatedElementsRuleFactory2.java | 55 -- ...StructuralRelatedGetSetObjRuleFactory.java | 55 -- .../TypeRelatedElementsRuleFactory2.java | 55 -- .../TypeRelatedGetSetObjRuleFactory.java | 55 -- .../TypeRelatedGetSetValueRuleFactory.java | 112 ----- .../factories/UpdateMethodFactory.java | 70 --- .../rules/domain/RelatedObjectAccessor.java | 111 ---- .../rules/domain/RelatedObjectsAccessor.java | 113 ----- .../RelatedOrderedSetElementsAccessor.java | 86 ---- .../rules/domain/RelatedValueAccessor.java | 150 ------ .../StructuralRelatedObjectAccessor.java | 131 ----- .../StructuralRelatedObjectsAccessor.java | 116 ----- .../rules/domain/StructuralUtils.java | 116 ----- .../structural/schema/AdaptedLinkType.java | 90 ---- .../structural/schema/DefaultSchema.java | 123 ----- .../structural/schema/MappingSchemas.java | 266 ---------- .../schema/OrderedSetSimpleLinkType.java | 28 -- .../structural/schema/SimpleLinkType.java | 190 ------- pom.xml | 1 - 150 files changed, 8552 deletions(-) delete mode 100644 org.simantics.objmap2/.classpath delete mode 100644 org.simantics.objmap2/.project delete mode 100644 org.simantics.objmap2/.settings/org.eclipse.jdt.core.prefs delete mode 100644 org.simantics.objmap2/META-INF/MANIFEST.MF delete mode 100644 org.simantics.objmap2/build.properties delete mode 100644 org.simantics.objmap2/pom.xml delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/backward/IBackwardLinkType.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/backward/IBackwardMapping.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/backward/IBackwardMappingRule.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/backward/IBackwardMappingSchema.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/bidirectional/IBidirectionalLinkType.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/bidirectional/IBidirectionalMapping.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/bidirectional/IBidirectionalMappingRule.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/bidirectional/IBidirectionalMappingSchema.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/exceptions/MappingException.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/forward/IForwardLinkType.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/forward/IForwardMapping.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/forward/IForwardMappingRule.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/forward/IForwardMappingSchema.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/IMapping.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/IMappingListener.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/Mappings.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/Composition.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/CompoundRelatedGetValue.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/CompoundRelatedSetValue.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/DynamicGraphType.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/GetType.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/GraphType.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/HasCollectionAdder.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/HasCollectionRemover.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/HasSetter.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/OptionalRelatedElements.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/OrderedElementsAdd.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/OrderedElementsGet.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/OrderedElementsRem.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/OrderedSetType.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/RelatedElement.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/RelatedElements.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/RelatedElementsAdd.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/RelatedElementsGet.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/RelatedElementsRem.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/RelatedGetObj.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/RelatedGetValue.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/RelatedOrderedSetElements.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/RelatedSetObj.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/RelatedSetValue.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/RelatedValue.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/SetType.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/UpdateMethod.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/factories/CompoundRelatedGetSetValueRuleFactory.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/factories/DataTypeUtils.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/factories/OptionalRelatedElementsRuleFactory.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/factories/OrderedElementsRuleFactory.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/factories/RelatedElementRuleFactory.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/factories/RelatedElementsRuleFactory.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/factories/RelatedElementsRuleFactory2.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/factories/RelatedGetSetObjRuleFactory.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/factories/RelatedGetSetValueRuleFactory.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/factories/RelatedOrderedSetElementsRuleFactory.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/factories/RelatedValueRuleFactory.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/factories/UpdateMethodFactory.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/meta/IsClassRule.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/meta/IsCollectionRule.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/meta/IsFieldRule.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/meta/IsGetSetRule.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/meta/IsMethodRule.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/impl/Link.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/impl/Mapping.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/impl/RangeUpdateRequest.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/rules/MappedElementRule.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/rules/MappedElementsRule.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/rules/ValueRule.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/rules/adapters/IdentityAdapter.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/rules/adapters/ValueAdapter.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/rules/domain/CompoundValueAccessor.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/rules/domain/IDomainAccessor.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/rules/domain/MappingUtils.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/rules/domain/RelatedObjectAccessor.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/rules/domain/RelatedObjectsAccessor.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/rules/domain/RelatedOrderedSetElementsAccessor.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/rules/domain/RelatedValueAccessor.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/rules/factory/IClassRuleFactory.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/rules/factory/ICollectionRuleFactory.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/rules/factory/IFieldRuleFactory.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/rules/factory/IGetSetRuleFactory.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/rules/factory/IMethodRuleFactory.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/rules/range/AdaptedRangeAccessor.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/rules/range/CollectionAccessor.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/rules/range/CompoundGetSetValueAccessor.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/rules/range/FieldAccessor.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/rules/range/FieldAccessorWithDefault.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/rules/range/GetSetObjectAccessor.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/rules/range/GetSetValueAccessor.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/rules/range/IRangeAccessor.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/rules/range/ListAccessor.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/schema/AdaptedLinkType.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/schema/DefaultSchema.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/schema/DynamicSimpleLinkType.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/schema/ILinkType.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/schema/IMappingSchema.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/schema/MappingSchemas.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/schema/OrderedSetSimpleLinkType.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/schema/SimpleLinkType.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/graph/schema/SimpleSchema.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/internal/BidirectionalLink.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/internal/BidirectionalMapping.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/internal/MonotoneBackwardMapping.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/internal/MonotoneForwardMapping.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/structural/IStructuralObject.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/structural/StructuralResource.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/StructuralRelatedElementsAdd.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/StructuralRelatedElementsGet.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/StructuralRelatedElementsRem.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/StructuralRelatedGetObj.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/StructuralRelatedSetObj.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/TypeRelatedElementsAdd.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/TypeRelatedElementsGet.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/TypeRelatedElementsRem.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/TypeRelatedGetObj.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/TypeRelatedGetValue.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/TypeRelatedSetObj.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/TypeRelatedSetValue.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/factories/DataTypeUtils.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/factories/OptionalRelatedElementsRuleFactory.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/factories/RelatedElementRuleFactory.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/factories/RelatedElementsRuleFactory.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/factories/RelatedElementsRuleFactory2.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/factories/RelatedGetSetObjRuleFactory.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/factories/RelatedGetSetValueRuleFactory.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/factories/RelatedOrderedSetElementsRuleFactory.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/factories/RelatedValueRuleFactory.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/factories/StructuralRelatedElementsRuleFactory2.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/factories/StructuralRelatedGetSetObjRuleFactory.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/factories/TypeRelatedElementsRuleFactory2.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/factories/TypeRelatedGetSetObjRuleFactory.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/factories/TypeRelatedGetSetValueRuleFactory.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/factories/UpdateMethodFactory.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/structural/rules/domain/RelatedObjectAccessor.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/structural/rules/domain/RelatedObjectsAccessor.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/structural/rules/domain/RelatedOrderedSetElementsAccessor.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/structural/rules/domain/RelatedValueAccessor.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/structural/rules/domain/StructuralRelatedObjectAccessor.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/structural/rules/domain/StructuralRelatedObjectsAccessor.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/structural/rules/domain/StructuralUtils.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/structural/schema/AdaptedLinkType.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/structural/schema/DefaultSchema.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/structural/schema/MappingSchemas.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/structural/schema/OrderedSetSimpleLinkType.java delete mode 100644 org.simantics.objmap2/src/org/simantics/objmap/structural/schema/SimpleLinkType.java diff --git a/org.simantics.objmap2/.classpath b/org.simantics.objmap2/.classpath deleted file mode 100644 index e801ebfb..00000000 --- a/org.simantics.objmap2/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/org.simantics.objmap2/.project b/org.simantics.objmap2/.project deleted file mode 100644 index 25f87237..00000000 --- a/org.simantics.objmap2/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - org.simantics.objmap2 - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - - diff --git a/org.simantics.objmap2/.settings/org.eclipse.jdt.core.prefs b/org.simantics.objmap2/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 7adc0fb9..00000000 --- a/org.simantics.objmap2/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,10 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 -org.eclipse.jdt.core.compiler.compliance=11 -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning -org.eclipse.jdt.core.compiler.release=enabled -org.eclipse.jdt.core.compiler.source=11 diff --git a/org.simantics.objmap2/META-INF/MANIFEST.MF b/org.simantics.objmap2/META-INF/MANIFEST.MF deleted file mode 100644 index 2e5ead63..00000000 --- a/org.simantics.objmap2/META-INF/MANIFEST.MF +++ /dev/null @@ -1,26 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: Objmap2 -Bundle-SymbolicName: org.simantics.objmap2 -Bundle-Version: 1.0.0.qualifier -Bundle-RequiredExecutionEnvironment: JavaSE-11 -Require-Bundle: org.simantics.db;bundle-version="1.1.0", - gnu.trove3;bundle-version="3.0.0", - org.eclipse.core.runtime;bundle-version="3.7.0", - org.simantics.layer0;bundle-version="1.0.0", - org.apache.log4j;bundle-version="1.2.15", - org.simantics.db.common;bundle-version="1.1.0", - org.simantics.structural.ontology;bundle-version="1.1.0" -Export-Package: org.simantics.objmap.backward, - org.simantics.objmap.bidirectional, - org.simantics.objmap.exceptions, - org.simantics.objmap.forward, - org.simantics.objmap.graph, - org.simantics.objmap.graph.annotations, - org.simantics.objmap.graph.annotations.factories, - org.simantics.objmap.graph.rules.factory, - org.simantics.objmap.graph.schema, - org.simantics.objmap.structural, - org.simantics.objmap.structural.annotations, - org.simantics.objmap.structural.schema -Automatic-Module-Name: org.simantics.objmap2 diff --git a/org.simantics.objmap2/build.properties b/org.simantics.objmap2/build.properties deleted file mode 100644 index eaa957cf..00000000 --- a/org.simantics.objmap2/build.properties +++ /dev/null @@ -1,15 +0,0 @@ -############################################################################### -# Copyright (c) 2012, 2013 Association for Decentralized Information Management in -# Industry THTH ry. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# VTT Technical Research Centre of Finland - initial API and implementation -############################################################################### -source.. = src/ -output.. = bin/ -bin.includes = META-INF/,\ - . diff --git a/org.simantics.objmap2/pom.xml b/org.simantics.objmap2/pom.xml deleted file mode 100644 index e1549450..00000000 --- a/org.simantics.objmap2/pom.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - 4.0.0 - - - org.simantics.g3d - org.simantics.g3d.root - 1.0.0-SNAPSHOT - - - org.simantics.objmap2 - eclipse-plugin - 1.0.0-SNAPSHOT - - diff --git a/org.simantics.objmap2/src/org/simantics/objmap/backward/IBackwardLinkType.java b/org.simantics.objmap2/src/org/simantics/objmap/backward/IBackwardLinkType.java deleted file mode 100644 index 847e996b..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/backward/IBackwardLinkType.java +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.backward; - -import org.simantics.db.WriteGraph; -import org.simantics.objmap.exceptions.MappingException; - -/** - * Contains rules for creating and updating domain elements for given - * range elements. - * @author Hannu Niemistö - */ -public interface IBackwardLinkType extends IBackwardMappingRule { - /** - * Creates a domain element based on a known range element. - */ - Domain createDomainElement(WriteGraph graph, Range rangeElement) throws MappingException; -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/backward/IBackwardMapping.java b/org.simantics.objmap2/src/org/simantics/objmap/backward/IBackwardMapping.java deleted file mode 100644 index c48e98b7..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/backward/IBackwardMapping.java +++ /dev/null @@ -1,30 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.backward; - -import java.util.Set; - -import org.simantics.db.WriteGraph; -import org.simantics.objmap.exceptions.MappingException; - -/** - * A backward mapping is a one-to-one correspondence between domain and range - * elements. It supports adding new range elements and creating corresponding - * domain elements. - * - * @author Hannu Niemistö - */ -public interface IBackwardMapping { - Set getRange(); - Domain inverseGet(Range rangeElement); - Domain inverseMap(WriteGraph graph, Range rangeElement) throws MappingException; -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/backward/IBackwardMappingRule.java b/org.simantics.objmap2/src/org/simantics/objmap/backward/IBackwardMappingRule.java deleted file mode 100644 index 7d3123d4..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/backward/IBackwardMappingRule.java +++ /dev/null @@ -1,29 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2013 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.backward; - -import org.simantics.db.WriteGraph; -import org.simantics.objmap.exceptions.MappingException; - -public interface IBackwardMappingRule { - /** - * Modifies the domain element so that it corresponds to the range element. - * @param g write transaction - * @param map unidirectional view of the current mapping - * @param domainElement the domain element that is updated - * @param rangeElement the range element that corresponds to the domain element - * @return true if the rule made some modifications - * @throws MappingException - */ - boolean updateDomain(WriteGraph graph, IBackwardMapping mapping, Domain domainElement, Range rangeElement) throws MappingException; - void createDomain(WriteGraph graph, IBackwardMapping mapping, Domain domainElement, Range rangeElement) throws MappingException; -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/backward/IBackwardMappingSchema.java b/org.simantics.objmap2/src/org/simantics/objmap/backward/IBackwardMappingSchema.java deleted file mode 100644 index ebf75f18..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/backward/IBackwardMappingSchema.java +++ /dev/null @@ -1,22 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.backward; - -import org.simantics.db.ReadGraph; -import org.simantics.objmap.exceptions.MappingException; - -public interface IBackwardMappingSchema { - /** - * @return Link type that should be used for the element. - */ - IBackwardLinkType linkTypeOfRangeElement(ReadGraph graph, Range element) throws MappingException; -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/bidirectional/IBidirectionalLinkType.java b/org.simantics.objmap2/src/org/simantics/objmap/bidirectional/IBidirectionalLinkType.java deleted file mode 100644 index f8662410..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/bidirectional/IBidirectionalLinkType.java +++ /dev/null @@ -1,21 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.bidirectional; - -import org.simantics.objmap.backward.IBackwardLinkType; -import org.simantics.objmap.forward.IForwardLinkType; - - -public interface IBidirectionalLinkType -extends IForwardLinkType, IBackwardLinkType, -IBidirectionalMappingRule { -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/bidirectional/IBidirectionalMapping.java b/org.simantics.objmap2/src/org/simantics/objmap/bidirectional/IBidirectionalMapping.java deleted file mode 100644 index dc4c5d1f..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/bidirectional/IBidirectionalMapping.java +++ /dev/null @@ -1,20 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.bidirectional; - -import org.simantics.objmap.backward.IBackwardMapping; -import org.simantics.objmap.forward.IForwardMapping; - - -public interface IBidirectionalMapping -extends IForwardMapping, IBackwardMapping { -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/bidirectional/IBidirectionalMappingRule.java b/org.simantics.objmap2/src/org/simantics/objmap/bidirectional/IBidirectionalMappingRule.java deleted file mode 100644 index ea6e931e..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/bidirectional/IBidirectionalMappingRule.java +++ /dev/null @@ -1,20 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2013 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.bidirectional; - -import org.simantics.objmap.backward.IBackwardMappingRule; -import org.simantics.objmap.forward.IForwardMappingRule; - - -public interface IBidirectionalMappingRule -extends IForwardMappingRule, IBackwardMappingRule { -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/bidirectional/IBidirectionalMappingSchema.java b/org.simantics.objmap2/src/org/simantics/objmap/bidirectional/IBidirectionalMappingSchema.java deleted file mode 100644 index b4942342..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/bidirectional/IBidirectionalMappingSchema.java +++ /dev/null @@ -1,24 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.bidirectional; - -import org.simantics.db.ReadGraph; -import org.simantics.objmap.backward.IBackwardMappingSchema; -import org.simantics.objmap.exceptions.MappingException; -import org.simantics.objmap.forward.IForwardMappingSchema; - - -public interface IBidirectionalMappingSchema -extends IForwardMappingSchema, IBackwardMappingSchema { - IBidirectionalLinkType linkTypeOfDomainElement(ReadGraph graph, Domain element) throws MappingException; - IBidirectionalLinkType linkTypeOfRangeElement(ReadGraph graph, Range element) throws MappingException; -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/exceptions/MappingException.java b/org.simantics.objmap2/src/org/simantics/objmap/exceptions/MappingException.java deleted file mode 100644 index 85b19be3..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/exceptions/MappingException.java +++ /dev/null @@ -1,35 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.exceptions; - -import org.simantics.db.exception.DatabaseException; - -public class MappingException extends DatabaseException { - private static final long serialVersionUID = 5381307568357191426L; - - - public MappingException() { - super(); - } - - public MappingException(String message) { - super(message); - } - - public MappingException(Throwable cause) { - super(cause); - } - - public MappingException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/forward/IForwardLinkType.java b/org.simantics.objmap2/src/org/simantics/objmap/forward/IForwardLinkType.java deleted file mode 100644 index 00e2b36a..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/forward/IForwardLinkType.java +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.forward; - -import org.simantics.db.ReadGraph; -import org.simantics.objmap.exceptions.MappingException; - -/** - * Contains rules for creating and updating range elements for given - * domain elements. - * @author Hannu Niemistö - */ -public interface IForwardLinkType extends IForwardMappingRule { - /** - * Creates a range element based on a known domain element. - */ - Range createRangeElement(ReadGraph graph, Domain domainElement) throws MappingException; -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/forward/IForwardMapping.java b/org.simantics.objmap2/src/org/simantics/objmap/forward/IForwardMapping.java deleted file mode 100644 index 1994b627..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/forward/IForwardMapping.java +++ /dev/null @@ -1,23 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.forward; - -import java.util.Set; - -import org.simantics.db.ReadGraph; -import org.simantics.objmap.exceptions.MappingException; - -public interface IForwardMapping { - Set getDomain(); - Range get(Domain domainElement); - Range map(ReadGraph graph, Domain domainElement) throws MappingException; -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/forward/IForwardMappingRule.java b/org.simantics.objmap2/src/org/simantics/objmap/forward/IForwardMappingRule.java deleted file mode 100644 index b64acc90..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/forward/IForwardMappingRule.java +++ /dev/null @@ -1,29 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2013 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.forward; - -import org.simantics.db.ReadGraph; -import org.simantics.objmap.exceptions.MappingException; - -public interface IForwardMappingRule { - /** - * Modifies the range element so that it corresponds to the domain element. - * @param g read transaction - * @param map unidirectional view of the current mapping - * @param domainElement the domain element that corresponds to the range element - * @param rangeElement the range element that is updated - * @return true if the rule made some modifications - * @throws MappingException - */ - boolean updateRange(ReadGraph graph, IForwardMapping mapping, Domain domainElement, Range rangeElement) throws MappingException; - void createRange(ReadGraph graph, IForwardMapping mapping, Domain domainElement, Range rangeElement) throws MappingException; -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/forward/IForwardMappingSchema.java b/org.simantics.objmap2/src/org/simantics/objmap/forward/IForwardMappingSchema.java deleted file mode 100644 index 5470c8e0..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/forward/IForwardMappingSchema.java +++ /dev/null @@ -1,22 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.forward; - -import org.simantics.db.ReadGraph; -import org.simantics.objmap.exceptions.MappingException; - -public interface IForwardMappingSchema { - /** - * @return Link type that should be used for the element. - */ - IForwardLinkType linkTypeOfDomainElement(ReadGraph graph, Domain element) throws MappingException; -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/IMapping.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/IMapping.java deleted file mode 100644 index 655c7162..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/IMapping.java +++ /dev/null @@ -1,142 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2013 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph; - -import java.util.Collection; -import java.util.Set; - -import org.simantics.db.Disposable; -import org.simantics.db.ReadGraph; -import org.simantics.db.WriteGraph; -import org.simantics.objmap.bidirectional.IBidirectionalMapping; -import org.simantics.objmap.exceptions.MappingException; - -/** - * A mapping consists of domain (a set of resources), range (a set of Java objects) and - * a set of links relating them. The mapping is used to propagate modifications of - * domain elements to range and vice versa. - * - * @see Manual - * - * @author Hannu Niemistö - */ -public interface IMapping extends Disposable, IBidirectionalMapping { - - /** - * Returns the domain of the mapping. All set operations are supported. - * Adding a new domain element does not automatically create a link to it. - * Removal of a domain element removes also a link and the target element, - * but does not remove the element from the database. - */ - Set getDomain(); - - /** - * Returns the range of the mapping. All set operations are supported. - * Adding a new range element does not automatically create a link to it. - * Removal of a range element removes also a link and the domain element, - * but does not remove the domain element from the database. - */ - Set getRange(); - - /** - * Updates all domain elements whose counterpart is modified and creates new - * domain elements for previously added range elements. Returns the - * collection of domain elements that were modified or created in the update - * process. - */ - Collection updateDomain(WriteGraph g) throws MappingException; - - /** - * Updates all range elements whose counterpart is modified and creates new - * range elements for previously added domain elements. Returns the - * collection of range elements that were modified or created in the update - * process. - */ - Collection updateRange(ReadGraph g) throws MappingException; - - /** - * Returns the counterpart of a domain element or null if the element does - * not belong to the domain or does not have a link. - */ - Range get(Domain domainElement); - - /** - * Returns the counterpart of a range element or null if the element does - * not belong to the range or does not have a link. - */ - Domain inverseGet(Range rangeElement); - - /** - * A convenience method that adds a domain element to the mapping and - * immediately updates the mapping and returns the corresponding range - * element. - */ - Range map(ReadGraph g, Domain domainElement) throws MappingException; - - /** - * A convenience method that adds a range element to the mapping and - * immediately updates the mapping and returns the corresponding domain - * element. - */ - Domain inverseMap(WriteGraph g, Range rangeElement) - throws MappingException; - - /** - * Tells the mapping that the domain element has been modified. - */ - void domainModified(Domain domainElement); - - /** - * Tells the mapping that the range element has been modified. - */ - void rangeModified(Range rangeElement); - - /** - * Tells if some domain elements have been modified or added. - */ - boolean isDomainModified(); - - /** - * Tells if some range elements have been modified or added. - */ - boolean isRangeModified(); - - Collection getDomainModified(); - Collection getRangeModified(); - - /** - * Returns a collection of domain elements which have been modified and also - * their counterparts in the mapping are modified. These elements are in - * conflict in the sense that the updating domain and range in different - * orders may produce different results. - */ - Collection getConflictingDomainElements(); - - /** - * Returns a collection of range elements which have been modified and also - * their counterparts in the mapping are modified. These elements are in - * conflict in the sense that the updating domain and range in different - * orders may produce different results. - */ - Collection getConflictingRangeElements(); - - /** - * Adds a listener for domain and range modifications. - */ - void addMappingListener(IMappingListener listener); - - /** - * Removes a previously added listener. - */ - void removeMappingListener(IMappingListener listener); - -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/IMappingListener.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/IMappingListener.java deleted file mode 100644 index 9f9888d7..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/IMappingListener.java +++ /dev/null @@ -1,30 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2013 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph; - -/** - * Listens modifications in a mapping. - * @author Hannu Niemistö - */ -public interface IMappingListener { - /** - * Called when some domain element is modified or created - * and the mapping was previously up to date. - */ - void domainModified(); - - /** - * Called when some range element is modified or created - * and the mapping was previously up to date. - */ - void rangeModified(); -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/Mappings.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/Mappings.java deleted file mode 100644 index ef609bc7..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/Mappings.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2013 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph; - -import org.simantics.objmap.graph.impl.Mapping; -import org.simantics.objmap.graph.schema.IMappingSchema; -/** - * Static utility methods for mappings. - * @author Hannu Niemistö - */ -public class Mappings { - private Mappings() {} - - /** - * Creates a new mapping based on the given mapping schema. - * The created mapping is not thread-safe and will not - * listen database changes automatically. - */ - public static IMapping createWithoutListening(IMappingSchema schema) { - return new Mapping(schema, false); - } - - /** - * Creates a new mapping based on the given mapping schema. - * The created mapping is not thread-safe. It listens database - * changes automatically. - */ - public static IMapping createWithListening(IMappingSchema schema) { - return new Mapping(schema, true); - } - - -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/Composition.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/Composition.java deleted file mode 100644 index 85aa9380..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/Composition.java +++ /dev/null @@ -1,22 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2013 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.FIELD,ElementType.METHOD}) -public @interface Composition { -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/CompoundRelatedGetValue.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/CompoundRelatedGetValue.java deleted file mode 100644 index f20199ef..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/CompoundRelatedGetValue.java +++ /dev/null @@ -1,30 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import org.simantics.objmap.graph.annotations.meta.IsGetSetRule; - - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) -@IsGetSetRule -@HasSetter(CompoundRelatedSetValue.class) -public @interface CompoundRelatedGetValue { - String objRelation(); - String objType(); - String valRelation(); -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/CompoundRelatedSetValue.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/CompoundRelatedSetValue.java deleted file mode 100644 index 4a089043..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/CompoundRelatedSetValue.java +++ /dev/null @@ -1,24 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) -public @interface CompoundRelatedSetValue { - String value(); -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/DynamicGraphType.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/DynamicGraphType.java deleted file mode 100644 index fe83d2dc..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/DynamicGraphType.java +++ /dev/null @@ -1,23 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -public @interface DynamicGraphType { - String value(); -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/GetType.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/GetType.java deleted file mode 100644 index 97542a33..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/GetType.java +++ /dev/null @@ -1,25 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - - - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) -public @interface GetType { - String value(); -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/GraphType.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/GraphType.java deleted file mode 100644 index 6b886a11..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/GraphType.java +++ /dev/null @@ -1,23 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -public @interface GraphType { - String value(); -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/HasCollectionAdder.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/HasCollectionAdder.java deleted file mode 100644 index a4301d6a..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/HasCollectionAdder.java +++ /dev/null @@ -1,24 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.annotations; - -import java.lang.annotation.Annotation; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.ANNOTATION_TYPE) -public @interface HasCollectionAdder { - Class value(); -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/HasCollectionRemover.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/HasCollectionRemover.java deleted file mode 100644 index c7fe7cde..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/HasCollectionRemover.java +++ /dev/null @@ -1,24 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.annotations; - -import java.lang.annotation.Annotation; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.ANNOTATION_TYPE) -public @interface HasCollectionRemover { - Class value(); -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/HasSetter.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/HasSetter.java deleted file mode 100644 index 9b32640b..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/HasSetter.java +++ /dev/null @@ -1,24 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.annotations; - -import java.lang.annotation.Annotation; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.ANNOTATION_TYPE) -public @interface HasSetter { - Class value(); -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/OptionalRelatedElements.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/OptionalRelatedElements.java deleted file mode 100644 index 297adaa6..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/OptionalRelatedElements.java +++ /dev/null @@ -1,29 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2013 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import org.simantics.objmap.graph.annotations.meta.IsFieldRule; - - - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.FIELD) -@IsFieldRule -public @interface OptionalRelatedElements { - String value(); - boolean composition() default false; -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/OrderedElementsAdd.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/OrderedElementsAdd.java deleted file mode 100644 index 08aa7fb4..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/OrderedElementsAdd.java +++ /dev/null @@ -1,22 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) -public @interface OrderedElementsAdd { -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/OrderedElementsGet.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/OrderedElementsGet.java deleted file mode 100644 index 88d3d8e1..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/OrderedElementsGet.java +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import org.simantics.objmap.graph.annotations.meta.IsCollectionRule; - - - - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) -@IsCollectionRule -@HasCollectionAdder(OrderedElementsAdd.class) -@HasCollectionRemover(OrderedElementsRem.class) -public @interface OrderedElementsGet { - boolean composition() default false; -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/OrderedElementsRem.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/OrderedElementsRem.java deleted file mode 100644 index c922f79f..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/OrderedElementsRem.java +++ /dev/null @@ -1,23 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) -public @interface OrderedElementsRem { -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/OrderedSetType.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/OrderedSetType.java deleted file mode 100644 index 0ae08afa..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/OrderedSetType.java +++ /dev/null @@ -1,23 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -public @interface OrderedSetType { - String value(); -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/RelatedElement.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/RelatedElement.java deleted file mode 100644 index 36c74aa3..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/RelatedElement.java +++ /dev/null @@ -1,26 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2013 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import org.simantics.objmap.graph.annotations.meta.IsFieldRule; - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.FIELD) -@IsFieldRule -public @interface RelatedElement { - String value(); -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/RelatedElements.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/RelatedElements.java deleted file mode 100644 index 6cbf6e11..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/RelatedElements.java +++ /dev/null @@ -1,28 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2013 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import org.simantics.objmap.graph.annotations.meta.IsFieldRule; - - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.FIELD) -@IsFieldRule -public @interface RelatedElements { - String value(); - boolean composition() default false; -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/RelatedElementsAdd.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/RelatedElementsAdd.java deleted file mode 100644 index 7f005d93..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/RelatedElementsAdd.java +++ /dev/null @@ -1,23 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) -public @interface RelatedElementsAdd { - String value(); -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/RelatedElementsGet.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/RelatedElementsGet.java deleted file mode 100644 index 46b1f035..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/RelatedElementsGet.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import org.simantics.objmap.graph.annotations.meta.IsCollectionRule; - - - - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) -@IsCollectionRule -@HasCollectionAdder(RelatedElementsAdd.class) -@HasCollectionRemover(RelatedElementsRem.class) -public @interface RelatedElementsGet { - String value(); - boolean composition() default false; -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/RelatedElementsRem.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/RelatedElementsRem.java deleted file mode 100644 index c25aa5d1..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/RelatedElementsRem.java +++ /dev/null @@ -1,24 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) -public @interface RelatedElementsRem { - String value(); -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/RelatedGetObj.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/RelatedGetObj.java deleted file mode 100644 index 30bcc8d6..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/RelatedGetObj.java +++ /dev/null @@ -1,30 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import org.simantics.objmap.graph.annotations.meta.IsGetSetRule; - - - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) -//@HasGetSetRuleFactory(RelatedGetSetObjRuleFactory.class) -@IsGetSetRule -@HasSetter(RelatedSetObj.class) -public @interface RelatedGetObj { - String value(); -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/RelatedGetValue.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/RelatedGetValue.java deleted file mode 100644 index 163cf30d..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/RelatedGetValue.java +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import org.simantics.objmap.graph.annotations.meta.IsGetSetRule; -import org.simantics.objmap.graph.rules.adapters.IdentityAdapter; -import org.simantics.objmap.graph.rules.adapters.ValueAdapter; - - - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) -//@HasGetSetRuleFactory(RelatedGetSetValueRuleFactory.class) -@IsGetSetRule -@HasSetter(RelatedSetValue.class) -public @interface RelatedGetValue { - String value(); - Class adapter() default IdentityAdapter.class; -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/RelatedOrderedSetElements.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/RelatedOrderedSetElements.java deleted file mode 100644 index d437288a..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/RelatedOrderedSetElements.java +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2013 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import org.simantics.objmap.graph.annotations.meta.IsFieldRule; - - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.FIELD) -@IsFieldRule -public @interface RelatedOrderedSetElements { - boolean composition() default false; -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/RelatedSetObj.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/RelatedSetObj.java deleted file mode 100644 index f57651c1..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/RelatedSetObj.java +++ /dev/null @@ -1,24 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) -public @interface RelatedSetObj { - String value(); -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/RelatedSetValue.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/RelatedSetValue.java deleted file mode 100644 index 09c8c52c..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/RelatedSetValue.java +++ /dev/null @@ -1,24 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) -public @interface RelatedSetValue { - String value(); -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/RelatedValue.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/RelatedValue.java deleted file mode 100644 index 8f61c2f1..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/RelatedValue.java +++ /dev/null @@ -1,36 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2013 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import org.simantics.objmap.graph.annotations.meta.IsFieldRule; -import org.simantics.objmap.graph.rules.adapters.IdentityAdapter; -import org.simantics.objmap.graph.rules.adapters.ValueAdapter; - - - -/** - * Specifies a correspondence between a field and - * functional property. - * @author Hannu Niemistö - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.FIELD) -@IsFieldRule -public @interface RelatedValue { - String value(); - Class adapter() default IdentityAdapter.class; -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/SetType.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/SetType.java deleted file mode 100644 index c3f8b4d8..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/SetType.java +++ /dev/null @@ -1,25 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - - - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) -public @interface SetType { - String value(); -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/UpdateMethod.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/UpdateMethod.java deleted file mode 100644 index 841340a6..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/UpdateMethod.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2013 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import org.simantics.objmap.graph.annotations.meta.IsFieldRule; - - - -/** - * Specifies that the annotated method should be called - * to update range object. - * @author Hannu Niemistö - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) -@IsFieldRule -public @interface UpdateMethod { -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/factories/CompoundRelatedGetSetValueRuleFactory.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/factories/CompoundRelatedGetSetValueRuleFactory.java deleted file mode 100644 index 2120b50f..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/factories/CompoundRelatedGetSetValueRuleFactory.java +++ /dev/null @@ -1,110 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.annotations.factories; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Method; - -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.exception.DatabaseException; -import org.simantics.layer0.Layer0; -import org.simantics.objmap.bidirectional.IBidirectionalMappingRule; -import org.simantics.objmap.graph.annotations.CompoundRelatedGetValue; -import org.simantics.objmap.graph.annotations.CompoundRelatedSetValue; -import org.simantics.objmap.graph.rules.ValueRule; -import org.simantics.objmap.graph.rules.domain.CompoundValueAccessor; -import org.simantics.objmap.graph.rules.factory.IGetSetRuleFactory; -import org.simantics.objmap.graph.rules.range.CompoundGetSetValueAccessor; -import org.simantics.objmap.graph.rules.range.IRangeAccessor; - -/** - * Rule factory for mapped value using Getter/Setter-methods. - * - * @author Marko Luukkainen - * - */ -public class CompoundRelatedGetSetValueRuleFactory implements IGetSetRuleFactory { - - @Override - public IBidirectionalMappingRule create(ReadGraph g, Annotation annotation, - Method getter, Method setter) - throws DatabaseException { - CompoundRelatedGetValue getterAnn = (CompoundRelatedGetValue)annotation; - -// Class adapterClass = getterAnn.adapter(); - IRangeAccessor rangeAccessor = new CompoundGetSetValueAccessor(getter, setter); -// Resource valueType; -// if (adapterClass == IdentityAdapter.class) { -// valueType = dataTypeOfClass(g, getter.getReturnType()); -// } else { -// try{ -// ValueAdapter adapter = adapterClass.newInstance(); -// rangeAccessor = new AdaptedRangeAccessor(rangeAccessor, adapter); -// valueType = adapter.rangeTypeToDomainType(g, getter.getReturnType()); -// } catch (InstantiationException e) { -// throw new RuntimeException(e); -// } catch (IllegalAccessException e) { -// throw new RuntimeException(e); -// } -// } - return new ValueRule(new CompoundValueAccessor(g.getResource(getterAnn.objRelation()), - g.getResource(getterAnn.objType()), - g.getResource(getterAnn.valRelation())), - rangeAccessor); - } - - @Override - public boolean isSetter(Annotation getterAnnotation, Annotation annotation) { - CompoundRelatedGetValue getterAnn = (CompoundRelatedGetValue)getterAnnotation; - CompoundRelatedSetValue setterAnn = (CompoundRelatedSetValue)annotation; - return getterAnn.objRelation().equals(setterAnn.value()); - } - - public static Resource dataTypeOfClass(ReadGraph g, Class clazz) { - Layer0 b = Layer0.getInstance(g); - if(clazz.equals(Double.class) || clazz.equals(double.class)) - return b.Double; - else if(clazz.equals(String.class)) - return b.String; - else if(clazz.equals(Integer.class) || clazz.equals(int.class)) - return b.Integer; - else if(clazz.equals(Float.class) || clazz.equals(float.class)) - return b.Float; - else if(clazz.equals(Boolean.class) || clazz.equals(boolean.class)) - return b.Boolean; - else if(clazz.equals(Long.class) || clazz.equals(long.class)) - return b.Long; - else if(clazz.equals(Byte.class) || clazz.equals(byte.class)) - return b.Byte; - - else if(clazz.equals(double[].class)) - return b.DoubleArray; - else if(clazz.equals(int[].class)) - return b.IntegerArray; - else if(clazz.equals(byte[].class)) - return b.ByteArray; - else if(clazz.equals(float[].class)) - return b.FloatArray; - else if(clazz.equals(boolean[].class)) - return b.BooleanArray; - else if(clazz.equals(String[].class)) - return b.StringArray; - else if(clazz.equals(long[].class)) - return b.LongArray; - else { - System.out.println("Couldn't find a data type for " + clazz); - return null; - } - } - -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/factories/DataTypeUtils.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/factories/DataTypeUtils.java deleted file mode 100644 index 6fe7f930..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/factories/DataTypeUtils.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2013 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.annotations.factories; - -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.layer0.Layer0; - -public class DataTypeUtils { - - public static Resource dataTypeOfClass(ReadGraph g, Class clazz) { - Layer0 b = Layer0.getInstance(g); - if(clazz.equals(Double.class) || clazz.equals(double.class)) - return b.Double; - else if(clazz.equals(String.class)) - return b.String; - else if(clazz.equals(Integer.class) || clazz.equals(int.class)) - return b.Integer; - else if(clazz.equals(Float.class) || clazz.equals(float.class)) - return b.Float; - else if(clazz.equals(Boolean.class) || clazz.equals(boolean.class)) - return b.Boolean; - else if(clazz.equals(Long.class) || clazz.equals(long.class)) - return b.Long; - else if(clazz.equals(Byte.class) || clazz.equals(byte.class)) - return b.Byte; - - else if(clazz.equals(double[].class)) - return b.DoubleArray; - else if(clazz.equals(int[].class)) - return b.IntegerArray; - else if(clazz.equals(byte[].class)) - return b.ByteArray; - else if(clazz.equals(float[].class)) - return b.FloatArray; - else if(clazz.equals(boolean[].class)) - return b.BooleanArray; - else if(clazz.equals(String[].class)) - return b.StringArray; - else if(clazz.equals(long[].class)) - return b.LongArray; - else { - System.out.println("Couldn't find a data type for " + clazz); - return null; - } - } - -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/factories/OptionalRelatedElementsRuleFactory.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/factories/OptionalRelatedElementsRuleFactory.java deleted file mode 100644 index 84b1134a..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/factories/OptionalRelatedElementsRuleFactory.java +++ /dev/null @@ -1,44 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2013 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.annotations.factories; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Field; -import java.util.Collection; -import java.util.Collections; - -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.exception.ResourceNotFoundException; -import org.simantics.db.exception.ServiceException; -import org.simantics.db.exception.ValidationException; -import org.simantics.objmap.bidirectional.IBidirectionalMappingRule; -import org.simantics.objmap.graph.annotations.OptionalRelatedElements; -import org.simantics.objmap.graph.rules.MappedElementsRule; -import org.simantics.objmap.graph.rules.domain.RelatedObjectsAccessor; -import org.simantics.objmap.graph.rules.factory.IFieldRuleFactory; -import org.simantics.objmap.graph.rules.range.FieldAccessorWithDefault; - - -public class OptionalRelatedElementsRuleFactory implements IFieldRuleFactory { - - @Override - public IBidirectionalMappingRule create(ReadGraph g, Annotation _annotation, Field field) throws ResourceNotFoundException, ValidationException, ServiceException { - OptionalRelatedElements annotation = (OptionalRelatedElements)_annotation; - return new MappedElementsRule( - new RelatedObjectsAccessor(g.getResource(annotation.value()), - annotation.composition()), - new FieldAccessorWithDefault>(field, Collections.emptyList()) - ); - } - -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/factories/OrderedElementsRuleFactory.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/factories/OrderedElementsRuleFactory.java deleted file mode 100644 index aeaea5fc..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/factories/OrderedElementsRuleFactory.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.annotations.factories; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Method; - -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.exception.DatabaseException; -import org.simantics.objmap.bidirectional.IBidirectionalMappingRule; -import org.simantics.objmap.graph.annotations.OrderedElementsAdd; -import org.simantics.objmap.graph.annotations.OrderedElementsGet; -import org.simantics.objmap.graph.annotations.OrderedElementsRem; -import org.simantics.objmap.graph.rules.MappedElementsRule; -import org.simantics.objmap.graph.rules.domain.RelatedOrderedSetElementsAccessor; -import org.simantics.objmap.graph.rules.factory.ICollectionRuleFactory; -import org.simantics.objmap.graph.rules.range.ListAccessor; - - -public class OrderedElementsRuleFactory implements ICollectionRuleFactory { - - @Override - public IBidirectionalMappingRule create(ReadGraph g, Annotation annotation, - Method getter, Method adder, Method remover) - throws DatabaseException { - OrderedElementsGet getterAnn = (OrderedElementsGet)annotation; - return new MappedElementsRule(new RelatedOrderedSetElementsAccessor(getterAnn.composition()), - new ListAccessor(getter, adder, remover)); - } - - @Override - public boolean isAdder(Annotation getterAnnotation, Annotation annotation) { - OrderedElementsGet getterAnn = (OrderedElementsGet)getterAnnotation; - OrderedElementsAdd adderAnn = (OrderedElementsAdd)annotation; - return true; - } - - @Override - public boolean isRemover(Annotation getterAnnotation, Annotation annotation) { - OrderedElementsGet getterAnn = (OrderedElementsGet)getterAnnotation; - OrderedElementsRem adderAnn = (OrderedElementsRem)annotation; - return true; - } - -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/factories/RelatedElementRuleFactory.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/factories/RelatedElementRuleFactory.java deleted file mode 100644 index 30281ee1..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/factories/RelatedElementRuleFactory.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2013 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.annotations.factories; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Field; - -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.exception.ResourceNotFoundException; -import org.simantics.db.exception.ServiceException; -import org.simantics.db.exception.ValidationException; -import org.simantics.objmap.bidirectional.IBidirectionalMappingRule; -import org.simantics.objmap.graph.annotations.RelatedElement; -import org.simantics.objmap.graph.rules.MappedElementRule; -import org.simantics.objmap.graph.rules.domain.RelatedObjectAccessor; -import org.simantics.objmap.graph.rules.factory.IFieldRuleFactory; -import org.simantics.objmap.graph.rules.range.FieldAccessor; - - -public class RelatedElementRuleFactory implements IFieldRuleFactory { - - @Override - public IBidirectionalMappingRule create(ReadGraph g, Annotation _annotation, Field field) throws ResourceNotFoundException, ValidationException, ServiceException { - RelatedElement annotation = (RelatedElement)_annotation; - return new MappedElementRule( - new RelatedObjectAccessor(g.getResource(annotation.value())), - new FieldAccessor(field) - ); - } - -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/factories/RelatedElementsRuleFactory.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/factories/RelatedElementsRuleFactory.java deleted file mode 100644 index d5cce134..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/factories/RelatedElementsRuleFactory.java +++ /dev/null @@ -1,43 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2013 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.annotations.factories; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Field; -import java.util.Collection; - -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.exception.ResourceNotFoundException; -import org.simantics.db.exception.ServiceException; -import org.simantics.db.exception.ValidationException; -import org.simantics.objmap.bidirectional.IBidirectionalMappingRule; -import org.simantics.objmap.graph.annotations.RelatedElements; -import org.simantics.objmap.graph.rules.MappedElementsRule; -import org.simantics.objmap.graph.rules.domain.RelatedObjectsAccessor; -import org.simantics.objmap.graph.rules.factory.IFieldRuleFactory; -import org.simantics.objmap.graph.rules.range.FieldAccessor; - - -public class RelatedElementsRuleFactory implements IFieldRuleFactory { - - @Override - public IBidirectionalMappingRule create(ReadGraph g, Annotation _annotation, Field field) throws ResourceNotFoundException, ValidationException, ServiceException { - RelatedElements annotation = (RelatedElements)_annotation; - return new MappedElementsRule( - new RelatedObjectsAccessor(g.getResource(annotation.value()), - annotation.composition()), - new FieldAccessor>(field) - ); - } - -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/factories/RelatedElementsRuleFactory2.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/factories/RelatedElementsRuleFactory2.java deleted file mode 100644 index ae0649d3..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/factories/RelatedElementsRuleFactory2.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.annotations.factories; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Method; - -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.exception.DatabaseException; -import org.simantics.objmap.bidirectional.IBidirectionalMappingRule; -import org.simantics.objmap.graph.annotations.RelatedElementsAdd; -import org.simantics.objmap.graph.annotations.RelatedElementsGet; -import org.simantics.objmap.graph.annotations.RelatedElementsRem; -import org.simantics.objmap.graph.rules.MappedElementsRule; -import org.simantics.objmap.graph.rules.domain.RelatedObjectsAccessor; -import org.simantics.objmap.graph.rules.factory.ICollectionRuleFactory; -import org.simantics.objmap.graph.rules.range.CollectionAccessor; - - -public class RelatedElementsRuleFactory2 implements ICollectionRuleFactory { - - @Override - public IBidirectionalMappingRule create(ReadGraph g, Annotation annotation, - Method getter, Method adder, Method remover) - throws DatabaseException { - RelatedElementsGet getterAnn = (RelatedElementsGet)annotation; - return new MappedElementsRule(new RelatedObjectsAccessor(g.getResource(getterAnn.value()),getterAnn.composition()), - new CollectionAccessor(getter, adder, remover)); - } - - @Override - public boolean isAdder(Annotation getterAnnotation, Annotation annotation) { - RelatedElementsGet getterAnn = (RelatedElementsGet)getterAnnotation; - RelatedElementsAdd adderAnn = (RelatedElementsAdd)annotation; - return getterAnn.value().equals(adderAnn.value()); - } - - @Override - public boolean isRemover(Annotation getterAnnotation, Annotation annotation) { - RelatedElementsGet getterAnn = (RelatedElementsGet)getterAnnotation; - RelatedElementsRem adderAnn = (RelatedElementsRem)annotation; - return getterAnn.value().equals(adderAnn.value()); - } - -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/factories/RelatedGetSetObjRuleFactory.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/factories/RelatedGetSetObjRuleFactory.java deleted file mode 100644 index ffd46bb9..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/factories/RelatedGetSetObjRuleFactory.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.annotations.factories; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Method; - -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.exception.DatabaseException; -import org.simantics.objmap.bidirectional.IBidirectionalMappingRule; -import org.simantics.objmap.graph.annotations.RelatedGetObj; -import org.simantics.objmap.graph.annotations.RelatedSetObj; -import org.simantics.objmap.graph.rules.MappedElementRule; -import org.simantics.objmap.graph.rules.domain.RelatedObjectAccessor; -import org.simantics.objmap.graph.rules.factory.IGetSetRuleFactory; -import org.simantics.objmap.graph.rules.range.GetSetObjectAccessor; - - -/** - * Rule factory for mapped object using Getter/Setter-methods. - * - * @author Marko Luukkainen - * - */ -public class RelatedGetSetObjRuleFactory implements IGetSetRuleFactory { - - @Override - public IBidirectionalMappingRule create(ReadGraph g, Annotation annotation, - Method getter, Method setter) - throws DatabaseException { - RelatedGetObj getterAnn = (RelatedGetObj)annotation; - return new MappedElementRule(new RelatedObjectAccessor(g.getResource(getterAnn.value())), - new GetSetObjectAccessor(getter, setter)); - } - - @Override - public boolean isSetter(Annotation getterAnnotation, Annotation annotation) { - RelatedGetObj getterAnn = (RelatedGetObj)getterAnnotation; - RelatedSetObj setterAnn = (RelatedSetObj)annotation; - return getterAnn.value().equals(setterAnn.value()); - } - - - -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/factories/RelatedGetSetValueRuleFactory.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/factories/RelatedGetSetValueRuleFactory.java deleted file mode 100644 index 8e08c49e..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/factories/RelatedGetSetValueRuleFactory.java +++ /dev/null @@ -1,111 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.annotations.factories; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Method; - -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.exception.DatabaseException; -import org.simantics.layer0.Layer0; -import org.simantics.objmap.bidirectional.IBidirectionalMappingRule; -import org.simantics.objmap.graph.annotations.RelatedGetValue; -import org.simantics.objmap.graph.annotations.RelatedSetValue; -import org.simantics.objmap.graph.rules.ValueRule; -import org.simantics.objmap.graph.rules.adapters.IdentityAdapter; -import org.simantics.objmap.graph.rules.adapters.ValueAdapter; -import org.simantics.objmap.graph.rules.domain.RelatedValueAccessor; -import org.simantics.objmap.graph.rules.factory.IGetSetRuleFactory; -import org.simantics.objmap.graph.rules.range.AdaptedRangeAccessor; -import org.simantics.objmap.graph.rules.range.GetSetValueAccessor; -import org.simantics.objmap.graph.rules.range.IRangeAccessor; - -/** - * Rule factory for mapped value using Getter/Setter-methods. - * - * @author Marko Luukkainen - * - */ -public class RelatedGetSetValueRuleFactory implements IGetSetRuleFactory { - - @Override - public IBidirectionalMappingRule create(ReadGraph g, Annotation annotation, - Method getter, Method setter) - throws DatabaseException { - RelatedGetValue getterAnn = (RelatedGetValue)annotation; - - Class adapterClass = getterAnn.adapter(); - IRangeAccessor rangeAccessor = new GetSetValueAccessor(getter, setter); - Resource valueType; - if (adapterClass == IdentityAdapter.class) { - valueType = dataTypeOfClass(g, getter.getReturnType()); - } else { - try{ - ValueAdapter adapter = adapterClass.newInstance(); - rangeAccessor = new AdaptedRangeAccessor(rangeAccessor, adapter); - valueType = adapter.rangeTypeToDomainType(g, getter.getReturnType()); - } catch (InstantiationException e) { - throw new RuntimeException(e); - } catch (IllegalAccessException e) { - throw new RuntimeException(e); - } - } - return new ValueRule(new RelatedValueAccessor(g.getResource(getterAnn.value()), valueType), - rangeAccessor); - } - - @Override - public boolean isSetter(Annotation getterAnnotation, Annotation annotation) { - RelatedGetValue getterAnn = (RelatedGetValue)getterAnnotation; - RelatedSetValue setterAnn = (RelatedSetValue)annotation; - return getterAnn.value().equals(setterAnn.value()); - } - - public static Resource dataTypeOfClass(ReadGraph g, Class clazz) { - Layer0 b = Layer0.getInstance(g); - if(clazz.equals(Double.class) || clazz.equals(double.class)) - return b.Double; - else if(clazz.equals(String.class)) - return b.String; - else if(clazz.equals(Integer.class) || clazz.equals(int.class)) - return b.Integer; - else if(clazz.equals(Float.class) || clazz.equals(float.class)) - return b.Float; - else if(clazz.equals(Boolean.class) || clazz.equals(boolean.class)) - return b.Boolean; - else if(clazz.equals(Long.class) || clazz.equals(long.class)) - return b.Long; - else if(clazz.equals(Byte.class) || clazz.equals(byte.class)) - return b.Byte; - - else if(clazz.equals(double[].class)) - return b.DoubleArray; - else if(clazz.equals(int[].class)) - return b.IntegerArray; - else if(clazz.equals(byte[].class)) - return b.ByteArray; - else if(clazz.equals(float[].class)) - return b.FloatArray; - else if(clazz.equals(boolean[].class)) - return b.BooleanArray; - else if(clazz.equals(String[].class)) - return b.StringArray; - else if(clazz.equals(long[].class)) - return b.LongArray; - else { - System.out.println("Couldn't find a data type for " + clazz); - return null; - } - } - -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/factories/RelatedOrderedSetElementsRuleFactory.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/factories/RelatedOrderedSetElementsRuleFactory.java deleted file mode 100644 index 5cded548..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/factories/RelatedOrderedSetElementsRuleFactory.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2013 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.annotations.factories; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Field; -import java.util.Collection; - -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.exception.ResourceNotFoundException; -import org.simantics.db.exception.ServiceException; -import org.simantics.db.exception.ValidationException; -import org.simantics.objmap.bidirectional.IBidirectionalMappingRule; -import org.simantics.objmap.graph.annotations.RelatedOrderedSetElements; -import org.simantics.objmap.graph.rules.MappedElementsRule; -import org.simantics.objmap.graph.rules.domain.RelatedOrderedSetElementsAccessor; -import org.simantics.objmap.graph.rules.factory.IFieldRuleFactory; -import org.simantics.objmap.graph.rules.range.FieldAccessor; - - -public class RelatedOrderedSetElementsRuleFactory implements IFieldRuleFactory { - - @Override - public IBidirectionalMappingRule create(ReadGraph g, Annotation _annotation, Field field) throws ResourceNotFoundException, ValidationException, ServiceException { - RelatedOrderedSetElements annotation = (RelatedOrderedSetElements)_annotation; - return new MappedElementsRule( - new RelatedOrderedSetElementsAccessor(annotation.composition()), - new FieldAccessor>(field) - ); - } - -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/factories/RelatedValueRuleFactory.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/factories/RelatedValueRuleFactory.java deleted file mode 100644 index 52d6caa6..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/factories/RelatedValueRuleFactory.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2013 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.annotations.factories; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Field; - -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.exception.ResourceNotFoundException; -import org.simantics.db.exception.ServiceException; -import org.simantics.db.exception.ValidationException; - -import org.simantics.objmap.bidirectional.IBidirectionalMappingRule; -import org.simantics.objmap.graph.annotations.RelatedValue; -import org.simantics.objmap.graph.rules.ValueRule; -import org.simantics.objmap.graph.rules.adapters.IdentityAdapter; -import org.simantics.objmap.graph.rules.adapters.ValueAdapter; -import org.simantics.objmap.graph.rules.domain.RelatedValueAccessor; -import org.simantics.objmap.graph.rules.factory.IFieldRuleFactory; -import org.simantics.objmap.graph.rules.range.AdaptedRangeAccessor; -import org.simantics.objmap.graph.rules.range.FieldAccessor; -import org.simantics.objmap.graph.rules.range.IRangeAccessor; - - -public class RelatedValueRuleFactory implements IFieldRuleFactory { - - @Override - public IBidirectionalMappingRule create(ReadGraph g, Annotation _annotation, Field field) throws ResourceNotFoundException, - ValidationException, ServiceException { - RelatedValue annotation = (RelatedValue) _annotation; - Class adapterClass = annotation.adapter(); - IRangeAccessor rangeAccessor = new FieldAccessor(field); - Resource valueType; - if (adapterClass == IdentityAdapter.class) { - valueType = DataTypeUtils.dataTypeOfClass(g, field.getType()); - } else { - try { - ValueAdapter adapter = adapterClass.newInstance(); - rangeAccessor = new AdaptedRangeAccessor(rangeAccessor, adapter); - valueType = adapter.rangeTypeToDomainType(g, field.getType()); - } catch (InstantiationException e) { - throw new RuntimeException(e); - } catch (IllegalAccessException e) { - throw new RuntimeException(e); - } - } - return new ValueRule(new RelatedValueAccessor(g.getResource(annotation.value()), valueType), rangeAccessor); - } - -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/factories/UpdateMethodFactory.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/factories/UpdateMethodFactory.java deleted file mode 100644 index 5cb22fd5..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/factories/UpdateMethodFactory.java +++ /dev/null @@ -1,70 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2013 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.annotations.factories; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Method; - -import org.apache.log4j.Logger; -import org.simantics.db.ReadGraph; -import org.simantics.db.WriteGraph; -import org.simantics.db.exception.DatabaseException; -import org.simantics.objmap.backward.IBackwardMapping; -import org.simantics.objmap.bidirectional.IBidirectionalMappingRule; -import org.simantics.objmap.exceptions.MappingException; -import org.simantics.objmap.forward.IForwardMapping; -import org.simantics.objmap.graph.rules.factory.IMethodRuleFactory; - -public class UpdateMethodFactory implements IMethodRuleFactory { - - static Logger LOGGER = Logger.getLogger("org.simantics.objmap"); - - @Override - public IBidirectionalMappingRule create(ReadGraph g, - Annotation annotation, - final Method method) - throws DatabaseException { - method.setAccessible(true); - return new IBidirectionalMappingRule() { - - @Override - public boolean updateRange(ReadGraph g, IForwardMapping map, - Domain domainElement, Range rangeElement) - throws MappingException { - LOGGER.info(" UpdateMethodFactory.updateRange"); - try { - return (Boolean)method.invoke(rangeElement, g, domainElement); - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - return false; - } - - @Override - public boolean updateDomain(WriteGraph g, IBackwardMapping map, - Domain domainElement, Range rangeElement) - throws MappingException { - return false; - } - - public void createDomain(WriteGraph g, IBackwardMapping map, Domain domainElement, Range rangeElement) throws MappingException { - updateDomain(g, map, domainElement, rangeElement); - }; - - public void createRange(ReadGraph g, IForwardMapping map, Domain domainElement, Range rangeElement) throws MappingException { - updateRange(g, map, domainElement, rangeElement); - }; - }; - } - -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/meta/IsClassRule.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/meta/IsClassRule.java deleted file mode 100644 index 6373bf6d..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/meta/IsClassRule.java +++ /dev/null @@ -1,23 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2013 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.annotations.meta; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.ANNOTATION_TYPE) -public @interface IsClassRule { - -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/meta/IsCollectionRule.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/meta/IsCollectionRule.java deleted file mode 100644 index e96821f5..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/meta/IsCollectionRule.java +++ /dev/null @@ -1,23 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.annotations.meta; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.ANNOTATION_TYPE) -public @interface IsCollectionRule { - -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/meta/IsFieldRule.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/meta/IsFieldRule.java deleted file mode 100644 index 23670302..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/meta/IsFieldRule.java +++ /dev/null @@ -1,23 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2013 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.annotations.meta; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.ANNOTATION_TYPE) -public @interface IsFieldRule { -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/meta/IsGetSetRule.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/meta/IsGetSetRule.java deleted file mode 100644 index dd67932a..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/meta/IsGetSetRule.java +++ /dev/null @@ -1,24 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.annotations.meta; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.ANNOTATION_TYPE) -public @interface IsGetSetRule { - -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/meta/IsMethodRule.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/meta/IsMethodRule.java deleted file mode 100644 index 797ecc58..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/meta/IsMethodRule.java +++ /dev/null @@ -1,23 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2013 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.annotations.meta; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.ANNOTATION_TYPE) -public @interface IsMethodRule { -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/impl/Link.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/impl/Link.java deleted file mode 100644 index 2b2212e3..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/impl/Link.java +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2013 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -/** - * - */ -package org.simantics.objmap.graph.impl; - -import org.simantics.objmap.graph.schema.ILinkType; - - -/** - * An indication that the domain element corresponds to the range element - * in the mapping. The link type describes how source and target objects - * are updated. There are additionally flags for dirtiness of the link. - * @author Hannu Niemistö - */ -public class Link { - public ILinkType type; - public Domain domainElement; - public Range rangeElement; - - public boolean domainModified = false; - public boolean rangeModified = false; - public boolean removed = false; - - public Link(ILinkType type, Domain domainElement, Range rangeElement) { - this.type = type; - this.domainElement = domainElement; - this.rangeElement = rangeElement; - } -} \ No newline at end of file diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/impl/Mapping.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/impl/Mapping.java deleted file mode 100644 index ee1eb2e0..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/impl/Mapping.java +++ /dev/null @@ -1,476 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2013 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.impl; - - -import gnu.trove.map.hash.THashMap; - -import java.util.AbstractSet; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -import org.apache.log4j.Logger; -import org.simantics.db.ReadGraph; -import org.simantics.db.WriteGraph; -import org.simantics.db.exception.DatabaseException; - -import org.simantics.objmap.backward.IBackwardMapping; -import org.simantics.objmap.exceptions.MappingException; -import org.simantics.objmap.forward.IForwardMapping; -import org.simantics.objmap.graph.IMapping; -import org.simantics.objmap.graph.IMappingListener; -import org.simantics.objmap.graph.schema.ILinkType; -import org.simantics.objmap.graph.schema.IMappingSchema; - -/** - * An implementation of IMapping. The class should not be created - * directly but using methods in Mappings. - * @see org.simantics.objmap.graph.Mappings - * @author Hannu Niemistö - */ -public class Mapping implements IMapping { - - static Logger LOGGER = Logger.getLogger("org.simantics.objmap"); - - - IMappingSchema schema; - - THashMap> domain = new THashMap>(); - THashMap> range = new THashMap>(); - ArrayList listeners = new ArrayList(); - - ArrayList> modifiedDomainLinks = new ArrayList>(); - ArrayList> modifiedRangeLinks = new ArrayList>(); - - boolean disposed = false; - - boolean listensDomain; - - public Mapping(IMappingSchema schema, boolean listensDomain) { - this.schema = schema; - this.listensDomain = listensDomain; - } - - private void removeLink(Link link) { - if(link.domainModified) - modifiedDomainLinks.remove(link); - if(link.rangeModified) - modifiedRangeLinks.remove(link); - link.removed = true; - } - - private void createDomain(WriteGraph g, Link link) throws MappingException { - LOGGER.info(" createDomain for " + link.rangeElement); - ILinkType type = schema.linkTypeOfRangeElement(link.rangeElement); - Domain domainElement = type.createDomainElement(g, link.rangeElement); - link.type = type; - link.domainElement = domainElement; - domain.put(domainElement, link); - type.createDomain(g, new RangeToDomain(g), domainElement, link.rangeElement); - - // TODO Should we do this only if the mapping is listening? - domainModified(link); - } - - private void createRange(ReadGraph g, Link link) throws MappingException { - ILinkType type = schema.linkTypeOfDomainElement(g, link.domainElement); - Range rangeElement = type.createRangeElement(g, link.domainElement); - - link.type = type; - link.rangeElement = rangeElement; - range.put(rangeElement, link); - type.createRange(g, new DomainToRange(g), link.domainElement, rangeElement); - } - - Set domainSet = new AbstractSet() { - - public boolean add(Domain e) { - if(domain.containsKey(e)) - return false; - Link link = new Link(null, e, null); - domain.put(e, link); - modifiedDomainLinks.add(link); - return true; - } - - public boolean contains(Object o) { - return domain.contains(o); - } - - public boolean remove(Object o) { - Link link = domain.remove(o); - if(link == null) - return false; - removeLink(link); - if(link.rangeElement != null) - range.remove(link.rangeElement); - return true; - } - - @Override - public Iterator iterator() { - // FIXME does not implement Iterator.remove correctly - return domain.keySet().iterator(); - } - - @Override - public int size() { - return domain.size(); - } - - }; - - Set rangeSet = new AbstractSet() { - - public boolean add(Range e) { - if(range.containsKey(e)) - return false; - Link link = new Link(null, null, e); - range.put(e, link); - modifiedRangeLinks.add(link); - return true; - } - - public boolean contains(Object o) { - return range.contains(o); - } - - public boolean remove(Object o) { - Link link = range.remove(o); - if(link == null) - return false; - removeLink(link); - if(link.domainElement != null) - domain.remove(link.domainElement); - return true; - } - - @Override - public Iterator iterator() { - // FIXME does not implement Iterator.remove correctly - return range.keySet().iterator(); - } - - @Override - public int size() { - return range.size(); - } - - }; - - class DomainToRange implements IForwardMapping { - - ReadGraph g; - - public DomainToRange(ReadGraph g) { - this.g = g; - } - - @Override - public Range get(Domain element) { - Link link = domain.get(element); - if (link != null) - return link.rangeElement; - return null; - - } - - @Override - public Range map(ReadGraph graph, Domain element) - throws MappingException { - Link link = domain.get(element); - if(link == null) { - link = new Link(null, element, null); - link.domainModified = true; - modifiedDomainLinks.add(link); - domain.put(element, link); - createRange(g, link); - } - else if(link.type == null) - createRange(g, link); - return link.rangeElement; - } - - @Override - public Set getDomain() { - return domain.keySet(); - } - - }; - - class RangeToDomain extends DomainToRange implements IBackwardMapping { - - WriteGraph g; - - public RangeToDomain(WriteGraph g) { - super(g); - this.g = g; - } - @Override - public Domain inverseGet(Range element) { - - Link link = range.get(element); - if(link != null) - return link.domainElement; - return null; - } - - @Override - public Domain inverseMap(WriteGraph graph, Range element) - throws MappingException { - Link link = range.get(element); - if(link == null) { - link = new Link(null, null, element); - link.rangeModified = true; - modifiedRangeLinks.add(link); - range.put(element, link); - createDomain(g, link); - } - else if(link.type == null) - createDomain(g, link); - return link.domainElement; - } - - - @Override - public Set getRange() { - return range.keySet(); - } - }; - - @Override - public Set getDomain() { - return domainSet; - } - - @Override - public Set getRange() { - return rangeSet; - } - - - @Override - public synchronized Collection updateDomain(WriteGraph g) throws MappingException { - LOGGER.info("Mapping.updateDomain"); - RangeToDomain map = new RangeToDomain(g); - ArrayList updated = new ArrayList(); - while(!modifiedRangeLinks.isEmpty()) { - LOGGER.info(" modifiedRangeLinks.size() = " + modifiedRangeLinks.size()); - - Link link = modifiedRangeLinks.remove(modifiedRangeLinks.size()-1); - link.rangeModified = false; - /*if(link.domainModified) { - link.domainModified = false; - modifiedDomainLinks.remove(link); - }*/ - - if(link.type == null) { - createDomain(g, link); - } - - if(link.type.updateDomain(g, map, link.domainElement, link.rangeElement)) - updated.add(link.domainElement); - } - if (listensDomain) - updateRange(g); //FIXME: without this listening would stop. - return updated; - } - - @Override - public synchronized Collection updateRange(ReadGraph g) throws MappingException { - LOGGER.info("Mapping.updateRange"); - DomainToRange map = new DomainToRange(g); - ArrayList updated = new ArrayList(); - while(!modifiedDomainLinks.isEmpty()) { - LOGGER.info(" modifiedDomainLinks.size() = " + modifiedDomainLinks.size()); - - Link link = modifiedDomainLinks.remove(modifiedDomainLinks.size()-1); - link.domainModified = false; - /*if(link.rangeModified) { - link.rangeModified = false; - modifiedRangeLinks.remove(link); - }*/ - - if(link.type == null) { - createRange(g, link); - } - - if(listensDomain) { - RangeUpdateRequest request = new RangeUpdateRequest(link, map, this); - try { - g.syncRequest(request, request); - } catch (DatabaseException e) { - throw new MappingException(e); - } - // TODO check if really modified - updated.add(link.rangeElement); - } - else - if(link.type.updateRange(g, map, link.domainElement, link.rangeElement)) - updated.add(link.rangeElement); - } - return updated; - } - - @Override - public Range get(Domain domainElement) { - Link link = domain.get(domainElement); - if(link == null) - return null; - return link.rangeElement; - } - - @Override - public Domain inverseGet(Range rangeElement) { - Link link = range.get(rangeElement); - if(link == null) - return null; - return link.domainElement; - } - - @Override - public Domain inverseMap(WriteGraph g, Range rangeElement) throws MappingException { - getRange().add(rangeElement); - updateDomain(g); - return inverseGet(rangeElement); - } - - @Override - public Range map(ReadGraph g, Domain domainElement) throws MappingException { - getDomain().add(domainElement); - updateRange(g); - return get(domainElement); - } - - void domainModified(Link link) { - if(!link.domainModified) { - synchronized(modifiedDomainLinks) { - LOGGER.info(" domainModified for " + link.rangeElement); - link.domainModified = true; - modifiedDomainLinks.add(link); - if(modifiedDomainLinks.size() == 1) { - for(IMappingListener listener : listeners) - listener.domainModified(); - } - } - } - } - - @Override - public void domainModified(Domain domainElement) { - Link link = domain.get(domainElement); - if(link != null) - domainModified(link); - } - - void rangeModified(Link link) { - if(!link.rangeModified) { - synchronized(modifiedRangeLinks) { - link.rangeModified = true; - modifiedRangeLinks.add(link); - if(modifiedRangeLinks.size() == 1) { - for(IMappingListener listener : listeners) - listener.rangeModified(); - } - } - } - } - - @Override - public void rangeModified(Range rangeElement) { - Link link = range.get(rangeElement); - if(link != null) - rangeModified(link); - } - - @Override - public boolean isDomainModified() { - return !modifiedDomainLinks.isEmpty(); - } - - @Override - public boolean isRangeModified() { - return !modifiedRangeLinks.isEmpty(); - } - - @Override - public Collection getDomainModified() { - List list = new ArrayList(modifiedDomainLinks.size()); - for (Link link : modifiedDomainLinks) - list.add(link.domainElement); - return list; - - } - - @Override - public Collection getRangeModified() { - List list = new ArrayList(modifiedRangeLinks.size()); - for (Link link : modifiedRangeLinks) - list.add(link.rangeElement); - return list; - } - - @Override - public void addMappingListener(IMappingListener listener) { - listeners.add(listener); - } - - @Override - public void removeMappingListener(IMappingListener listener) { - listeners.remove(listener); - } - - @Override - public Collection getConflictingDomainElements() { - ArrayList result = new ArrayList(); - if(modifiedDomainLinks.size() < modifiedRangeLinks.size()) { - for(Link link : modifiedDomainLinks) - if(link.rangeModified) - result.add(link.domainElement); - } - else { - for(Link link : modifiedRangeLinks) - if(link.domainModified) - result.add(link.domainElement); - } - return result; - } - - @Override - public Collection getConflictingRangeElements() { - ArrayList result = new ArrayList(); - if(modifiedDomainLinks.size() < modifiedRangeLinks.size()) { - for(Link link : modifiedDomainLinks) - if(link.rangeModified) - result.add(link.rangeElement); - } - else { - for(Link link : modifiedRangeLinks) - if(link.domainModified) - result.add(link.rangeElement); - } - return result; - } - - @Override - public void dispose() { - disposed = true; - } - - public boolean isDisposed() { - return disposed; - } - -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/impl/RangeUpdateRequest.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/impl/RangeUpdateRequest.java deleted file mode 100644 index fed1918c..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/impl/RangeUpdateRequest.java +++ /dev/null @@ -1,77 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2013 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.impl; - -import org.simantics.db.ReadGraph; -import org.simantics.db.exception.DatabaseException; -import org.simantics.db.procedure.SyncListener; -import org.simantics.db.request.Read; - -import org.simantics.objmap.exceptions.MappingException; -import org.simantics.objmap.forward.IForwardMapping; -import org.simantics.objmap.graph.impl.Link; - - -public class RangeUpdateRequest implements Read, SyncListener { - - Link link; - /* - * Note that this map uses a read request that it has got from caller and - * not the one that is used in updateRange. This is intentional. - */ - IForwardMapping map; // map==null is used to flag that request is performed once - Mapping mapping; // mapping==null is used as a flag the request disposed - - public RangeUpdateRequest(Link link, IForwardMapping map, Mapping mapping) { - this.link = link; - this.map = map; - this.mapping = mapping; - } - - @Override - public Boolean perform(ReadGraph g) throws DatabaseException { - if(map != null) { - link.type.updateRange(g, map, link.domainElement, link.rangeElement); - map = null; - return Boolean.TRUE; - } - else if(mapping != null) { - mapping.domainModified(link); - mapping = null; - return Boolean.FALSE; - } - else - return null; - } - - @Override - public void exception(ReadGraph graph, Throwable throwable) - throws DatabaseException { - if(throwable instanceof DatabaseException) - throw (DatabaseException)throwable; - else - throw new MappingException(throwable); - } - - @Override - public void execute(ReadGraph graph, Boolean result) - throws DatabaseException { - } - - @Override - public boolean isDisposed() { - return mapping == null || link.removed || mapping.isDisposed(); - } - - - -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/MappedElementRule.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/MappedElementRule.java deleted file mode 100644 index 7454d738..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/MappedElementRule.java +++ /dev/null @@ -1,73 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2013 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.rules; - -import org.apache.log4j.Logger; -import org.simantics.db.ReadGraph; -import org.simantics.db.WriteGraph; -import org.simantics.objmap.backward.IBackwardMapping; -import org.simantics.objmap.bidirectional.IBidirectionalMappingRule; -import org.simantics.objmap.exceptions.MappingException; -import org.simantics.objmap.forward.IForwardMapping; -import org.simantics.objmap.graph.rules.domain.IDomainAccessor; -import org.simantics.objmap.graph.rules.range.IRangeAccessor; - - - - -/** - * A rule that synchronizes collection of elements between - * domain and range accessors. Elements are mapped from - * between domain and range during the synchronization. - * @author Hannu Niemistö - */ -public class MappedElementRule implements IBidirectionalMappingRule { - - static Logger LOGGER = Logger.getLogger("org.simantics.objmap"); - - IDomainAccessor domainAccessor; - IRangeAccessor rangeAccessor; - - public MappedElementRule(IDomainAccessor domainAccessor, - IRangeAccessor rangeAccessor) { - this.domainAccessor = domainAccessor; - this.rangeAccessor = rangeAccessor; - } - - @Override - public boolean updateDomain(WriteGraph g, IBackwardMapping map, - Domain domainElement, Range rangeElement) - throws MappingException { - LOGGER.info(" MappedElementRule.updateDomain"); - Range value = rangeAccessor.get(rangeElement); - Domain mappedValue = value == null ? null : map.inverseMap(g, value);//map.inverseGet(value); - return domainAccessor.set(g, domainElement, mappedValue); - } - - @Override - public boolean updateRange(ReadGraph g, IForwardMapping map, - Domain domainElement, Range rangeElement) - throws MappingException { - LOGGER.info(" MappedElementRule.updateRange"); - Domain value = domainAccessor.get(g, domainElement); - Range mappedValue = value == null ? null : map.map(g, value);////map.get(value); - return rangeAccessor.set(rangeElement, mappedValue); - } - - public void createDomain(WriteGraph g, IBackwardMapping map, Domain domainElement, Range rangeElement) throws MappingException { - updateDomain(g, map, domainElement, rangeElement); - }; - - public void createRange(ReadGraph g, IForwardMapping map, Domain domainElement, Range rangeElement) throws MappingException { - updateRange(g, map, domainElement, rangeElement); - }; -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/MappedElementsRule.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/MappedElementsRule.java deleted file mode 100644 index 202c9abc..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/MappedElementsRule.java +++ /dev/null @@ -1,82 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2013 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.rules; - -import java.util.ArrayList; -import java.util.Collection; - -import org.apache.log4j.Logger; -import org.simantics.db.ReadGraph; -import org.simantics.db.WriteGraph; -import org.simantics.objmap.backward.IBackwardMapping; -import org.simantics.objmap.bidirectional.IBidirectionalMappingRule; -import org.simantics.objmap.exceptions.MappingException; -import org.simantics.objmap.forward.IForwardMapping; -import org.simantics.objmap.graph.rules.domain.IDomainAccessor; -import org.simantics.objmap.graph.rules.range.IRangeAccessor; - - -/** - * A rule that synchronizes collection of elements between - * domain and range accessors. Elements are mapped from - * between domain and range during the synchronization. - * @author Hannu Niemistö - */ -public class MappedElementsRule implements IBidirectionalMappingRule { - - static Logger LOGGER = Logger.getLogger("org.simantics.objmap"); - - IDomainAccessor> domainAccessor; - IRangeAccessor> rangeAccessor; - - public MappedElementsRule(IDomainAccessor> domainAccessor, - IRangeAccessor> rangeAccessor) { - this.domainAccessor = domainAccessor; - this.rangeAccessor = rangeAccessor; - } - - @Override - public boolean updateDomain(WriteGraph g, IBackwardMapping map, - Domain domainElement, Range rangeElement) - throws MappingException { - LOGGER.info(" MappedElementsRule.updateDomain"); - // Snapshot the accessed range value for concurrency safety. - // NOTE: still assumes that the accessed collection is concurrent or - // synchronized for toArray to be atomic. - Collection value = rangeAccessor.get(rangeElement); - Object[] rangeSnapshot = value.toArray(); - ArrayList mappedValue = new ArrayList(rangeSnapshot.length); - for (Object obj : rangeSnapshot) - mappedValue.add(map.inverseMap(g, (Range)obj));//map.inverseGet((Range)obj)); - return domainAccessor.set(g, domainElement, mappedValue); - } - - @Override - public boolean updateRange(ReadGraph g, IForwardMapping map, - Domain domainElement, Range rangeElement) - throws MappingException { - LOGGER.info(" MappedElementsRule.updateRange"); - Collection value = domainAccessor.get(g, domainElement); - ArrayList mappedValue = new ArrayList(value.size()); - for(Domain r : value) - mappedValue.add(map.map(g, r));//map.get(r)); - return rangeAccessor.set(rangeElement, mappedValue); - } - - public void createDomain(WriteGraph g, IBackwardMapping map, Domain domainElement, Range rangeElement) throws MappingException { - updateDomain(g, map, domainElement, rangeElement); - }; - - public void createRange(ReadGraph g, IForwardMapping map, Domain domainElement, Range rangeElement) throws MappingException { - updateRange(g, map, domainElement, rangeElement); - }; -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/ValueRule.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/ValueRule.java deleted file mode 100644 index 231e14a0..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/ValueRule.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2013 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.rules; - -import org.apache.log4j.Logger; -import org.simantics.db.ReadGraph; -import org.simantics.db.WriteGraph; -import org.simantics.objmap.backward.IBackwardMapping; -import org.simantics.objmap.bidirectional.IBidirectionalMappingRule; -import org.simantics.objmap.exceptions.MappingException; -import org.simantics.objmap.forward.IForwardMapping; -import org.simantics.objmap.graph.rules.domain.IDomainAccessor; -import org.simantics.objmap.graph.rules.range.IRangeAccessor; - - -/** - * A rule that synchronizes values between domain and - * range accessors. - * @author Hannu Niemistö - */ -public class ValueRule implements IBidirectionalMappingRule { - - static Logger LOGGER = Logger.getLogger("org.simantics.objmap"); - - IDomainAccessor domainAccessor; - IRangeAccessor rangeAccessor; - - public ValueRule(IDomainAccessor domainAccessor, - IRangeAccessor rangeAccessor) { - this.domainAccessor = domainAccessor; - this.rangeAccessor = rangeAccessor; - } - - @Override - public boolean updateDomain(WriteGraph g, IBackwardMapping map, - Domain domainElement, Range rangeElement) - throws MappingException { - LOGGER.info(" ValueRule.updateDomain"); - Object value = rangeAccessor.get(rangeElement); - return domainAccessor.set(g, domainElement, value); - } - - @Override - public boolean updateRange(ReadGraph g, IForwardMapping map, - Domain domainElement, Range rangeElement) - throws MappingException { - LOGGER.info(" ValueRule.updateRange"); - Object value = domainAccessor.get(g, domainElement); - return rangeAccessor.set(rangeElement, value); - } - - public void createDomain(WriteGraph g, IBackwardMapping map, Domain domainElement, Range rangeElement) throws MappingException { - updateDomain(g, map, domainElement, rangeElement); - }; - public void createRange(ReadGraph g, IForwardMapping map, Domain domainElement, Range rangeElement) throws MappingException { - updateRange(g, map, domainElement, rangeElement); - }; -} - - diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/adapters/IdentityAdapter.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/adapters/IdentityAdapter.java deleted file mode 100644 index 77d12566..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/adapters/IdentityAdapter.java +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.rules.adapters; - -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; - -public enum IdentityAdapter implements ValueAdapter { - INSTANCE; - - @Override - public Object domainToRange(Object domainValue) { - return domainValue; - } - - @Override - public Object rangeToDomain(Object rangeValue) { - return rangeValue; - } - - @Override - public Resource rangeTypeToDomainType(ReadGraph graph, Class rangeType) { - return null; - } -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/adapters/ValueAdapter.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/adapters/ValueAdapter.java deleted file mode 100644 index 51a0f56e..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/adapters/ValueAdapter.java +++ /dev/null @@ -1,21 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.rules.adapters; - -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; - -public interface ValueAdapter { - Resource rangeTypeToDomainType(ReadGraph graph, Class rangeType); - Object domainToRange(Object domainValue); - Object rangeToDomain(Object rangeValue); -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/domain/CompoundValueAccessor.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/domain/CompoundValueAccessor.java deleted file mode 100644 index 4d29ac0a..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/domain/CompoundValueAccessor.java +++ /dev/null @@ -1,152 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2013 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.rules.domain; - -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; - -import org.apache.log4j.Logger; -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.Statement; -import org.simantics.db.WriteGraph; -import org.simantics.db.exception.DatabaseException; -import org.simantics.layer0.Layer0; -import org.simantics.objmap.exceptions.MappingException; -import org.simantics.objmap.graph.annotations.factories.CompoundRelatedGetSetValueRuleFactory; - -/** - * - * @author Marko Luukkainen - */ -public class CompoundValueAccessor implements IDomainAccessor { - - static Logger LOGGER = Logger.getLogger("org.simantics.objmap"); - - Resource objRelation; - Resource objType; - Resource valRelation; - - public CompoundValueAccessor(Resource objRelation, Resource objType, Resource valRelation) { - this.objRelation = objRelation; - this.objType = objType; - this.valRelation = valRelation; - } - - @Override - public Object get(ReadGraph g, Resource element) throws MappingException { - try { - Layer0 l0 = Layer0.getInstance(g); - LOGGER.info(" CompoundValueAccessor.get"); - Collection coll = g.getStatements(element, objRelation); - Map map = new HashMap(); - for (Statement c : coll) { - String name = g.getRelatedValue(c.getObject(), l0.HasName); - if (!map.containsKey(name) || !c.isAsserted(element)) - map.put(name, g.getRelatedValue(c.getObject(), valRelation)); - } - return map; - } catch (DatabaseException e) { - throw new MappingException(e); - } - } - - @Override - public boolean set(WriteGraph g, Resource element, Object v) - throws MappingException { - try { - Layer0 l0 = Layer0.getInstance(g); - LOGGER.info(" CompoundValueAccessor.set"); - @SuppressWarnings("unchecked") - Map values = (Map)v; - - Collection coll = g.getStatements(element, objRelation); - Map stmMap = new HashMap(); - Map valueMap = new HashMap(); - for (Statement c : coll) { - String name = g.getRelatedValue(c.getObject(), l0.HasName); - if (!stmMap.containsKey(name) || !c.isAsserted(element)) { - stmMap.put(name, c); - valueMap.put(name, g.getRelatedValue(c.getObject(), valRelation)); - } - } - boolean changed = false; - for (String key : values.keySet()) { - Object value = values.get(key); - if (value.equals(valueMap.get(key))) - continue; - changed = true; - Statement stm = stmMap.get(key); - if (stm == null || stm.isAsserted(element)) { - Resource obj = g.newResource(); - g.claim(obj, l0.InstanceOf, objType); - g.claimLiteral(obj, l0.HasName, key); - g.claim(element, objRelation, obj); - stm = getStatement(g, element, objRelation, obj); - } - - Statement valueStatement = g.getPossibleStatement(stm.getObject(), valRelation); - Resource valueType = CompoundRelatedGetSetValueRuleFactory.dataTypeOfClass(g, value.getClass()); - if(valueStatement == null) { - - Resource valueResource = g.newResource(); - g.claim(valueResource, Layer0.getInstance(g).InstanceOf, null, valueType); - g.claim(stm.getObject(), valRelation, valueResource); - g.claimValue(valueResource, value); - } else { - - - if (!valueStatement.isAsserted(stm.getObject())) - g.claimValue(valueStatement.getObject(), value); - else { - Resource valueResource = g.newResource(); - g.claim(valueResource, Layer0.getInstance(g).InstanceOf, null, - valueType); - g.claim(stm.getObject(), valRelation, valueResource); - g.claimValue(valueResource, value); - } - } - } - return changed; - - } catch (DatabaseException e) { - throw new MappingException(e); - } - - } - - private Statement getStatement(ReadGraph g, Resource s, Resource p, Resource o) throws DatabaseException{ - for (Statement stm : g.getStatements(s, p)) { - if (stm.getObject().equals(o)) - return stm; - } - return null; - } - - private boolean equals(Object o1, Object o2) { - if (o1 instanceof boolean[]) - Arrays.equals((boolean[])o1,(boolean[])o2); - if (o1 instanceof int[]) - Arrays.equals((int[])o1,(int[])o2); - if (o1 instanceof float[]) - Arrays.equals((float[])o1,(float[])o2); - if (o1 instanceof double[]) - Arrays.equals((double[])o1,(double[])o2); - if (o1 instanceof byte[]) - Arrays.equals((byte[])o1,(byte[])o2); - return o1.equals(o2); - - } - -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/domain/IDomainAccessor.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/domain/IDomainAccessor.java deleted file mode 100644 index d1a12e69..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/domain/IDomainAccessor.java +++ /dev/null @@ -1,26 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2013 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.rules.domain; - -import org.simantics.db.ReadGraph; -import org.simantics.db.WriteGraph; -import org.simantics.objmap.exceptions.MappingException; - - -/** - * Provides access to some property of domain elements. - * @author Hannu Niemistö - */ -public interface IDomainAccessor { - T get(ReadGraph g, Domain element) throws MappingException; - boolean set(WriteGraph g, Domain element, T value) throws MappingException; -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/domain/MappingUtils.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/domain/MappingUtils.java deleted file mode 100644 index 5e97f852..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/domain/MappingUtils.java +++ /dev/null @@ -1,92 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2013 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.rules.domain; - -import java.util.Arrays; -import java.util.Collection; - -import org.apache.log4j.Logger; -import org.simantics.db.Resource; -import org.simantics.db.WriteGraph; -import org.simantics.db.exception.DatabaseException; - -/** - * Static utility methods for rule implementations. - * @author Hannu Niemistö - */ -public class MappingUtils { - - static Logger LOGGER = Logger.getLogger("org.simantics.objmap"); - - /** - * Adds and removes statements to/from the database so that objects - * will be exactly the objects connected to subject by predicate. - * Returns true if the method made modifications to the database. - */ - public static boolean synchronizeStatements(WriteGraph g, Resource subject, Resource predicate, Resource[] objects, - boolean deleteExtraObjects) - throws DatabaseException { - Collection currentObjects0 = g.getObjects(subject, predicate); - Resource[] currentObjects = currentObjects0.toArray(new Resource[currentObjects0.size()]); - - Arrays.sort(objects); - Arrays.sort(currentObjects); - - boolean modified = false; - int i=0, j=0; - if(currentObjects.length > 0 && objects.length > 0) - while(true) { - int cmp = currentObjects[i].compareTo(objects[j]); - if(cmp < 0) { - LOGGER.info(" remove statement"); - if(deleteExtraObjects) - g.deny(currentObjects[i]); - else - g.denyStatement(subject, predicate, currentObjects[i]); - modified = true; - ++i; - if(i >= currentObjects.length) - break; - } - else if(cmp > 0) { - LOGGER.info(" add statement"); - g.claim(subject, predicate, objects[j]); - modified = true; - ++j; - if(j >= objects.length) - break; - } - else { - ++i; ++j; - if(i >= currentObjects.length) - break; - if(j >= objects.length) - break; - } - } - while(i < currentObjects.length) { - if(deleteExtraObjects) - g.deny(currentObjects[i]); - else - g.denyStatement(subject, predicate, currentObjects[i]); - modified = true; - ++i; - } - while(j < objects.length) { - g.claim(subject, predicate, objects[j]); - modified = true; - ++j; - } - return modified; - } - -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/domain/RelatedObjectAccessor.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/domain/RelatedObjectAccessor.java deleted file mode 100644 index 91a16478..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/domain/RelatedObjectAccessor.java +++ /dev/null @@ -1,71 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2013 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.rules.domain; - -import org.apache.log4j.Logger; -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.WriteGraph; -import org.simantics.db.exception.DatabaseException; -import org.simantics.objmap.exceptions.MappingException; - -/** - * Accesses a resource attached to the element by given functional relation. - * @author Hannu Niemistö - */ -public class RelatedObjectAccessor implements IDomainAccessor { - - static Logger LOGGER = Logger.getLogger("org.simantics.objmap"); - - Resource relation; - - public RelatedObjectAccessor(Resource relation) { - this.relation = relation; - } - - @Override - public Resource get(ReadGraph g, Resource element) throws MappingException { - try { - LOGGER.info(" RelatedObjectAccessor.get"); - return g.getPossibleObject(element, relation); - } catch (DatabaseException e) { - throw new MappingException(e); - } - } - - @Override - public boolean set(WriteGraph g, Resource element, Resource value) - throws MappingException { - try { - LOGGER.info(" RelatedObjectAccessor.set"); - Resource resource = g.getPossibleObject(element, relation); - if(resource == null) { - if(value == null) - return false; - g.claim(element, relation, value); - return true; - } - else if(resource.equals(value)) - return false; - else { - g.deny(element, relation); - if(value != null) - g.claim(element, relation, value); - return true; - } - } catch (DatabaseException e) { - throw new MappingException(e); - } - - } - -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/domain/RelatedObjectsAccessor.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/domain/RelatedObjectsAccessor.java deleted file mode 100644 index 5a9b1860..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/domain/RelatedObjectsAccessor.java +++ /dev/null @@ -1,63 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2013 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.rules.domain; - -import java.util.Collection; - -import org.apache.log4j.Logger; -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.WriteGraph; -import org.simantics.db.exception.DatabaseException; -import org.simantics.objmap.exceptions.MappingException; - -/** - * Accesses the set of objects attached to the element by the given relation. - * @author Hannu Niemistö - */ -public class RelatedObjectsAccessor implements IDomainAccessor> { - - static Logger LOGGER = Logger.getLogger("org.simantics.objmap"); - - Resource relation; - boolean deleteExtraObjects; - - public RelatedObjectsAccessor(Resource relation, boolean deleteExtraObjects) { - super(); - this.relation = relation; - this.deleteExtraObjects = deleteExtraObjects; - } - - @Override - public Collection get(ReadGraph g, Resource element) throws MappingException { - try { - LOGGER.info(" RelatedObjectsAccessor.get"); - return g.getObjects(element, relation); - } catch (DatabaseException e) { - throw new MappingException(e); - } - } - - @Override - public boolean set(WriteGraph g, Resource element, Collection value) - throws MappingException { - try { - LOGGER.info(" RelatedObjectsAccessor.set"); - return MappingUtils.synchronizeStatements(g, element, relation, - value.toArray(new Resource[value.size()]), deleteExtraObjects); - } catch (DatabaseException e) { - throw new MappingException(e); - } - - } - -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/domain/RelatedOrderedSetElementsAccessor.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/domain/RelatedOrderedSetElementsAccessor.java deleted file mode 100644 index 2190fef3..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/domain/RelatedOrderedSetElementsAccessor.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2013 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.rules.domain; - -import java.util.Collection; - -import org.apache.log4j.Logger; -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.WriteGraph; -import org.simantics.db.common.utils.OrderedSetUtils; -import org.simantics.db.exception.DatabaseException; -import org.simantics.objmap.exceptions.MappingException; - -/** - * Accesses the set of objects attached to the element by the given relation. - * @author Hannu Niemistö - */ -public class RelatedOrderedSetElementsAccessor implements IDomainAccessor> { - - static Logger LOGGER = Logger.getLogger("org.simantics.objmap"); - - boolean deleteExtraObjects; - - public RelatedOrderedSetElementsAccessor(boolean deleteExtraObjects) { - super(); - this.deleteExtraObjects = deleteExtraObjects; - } - - @Override - public Collection get(ReadGraph g, Resource element) throws MappingException { - try { - LOGGER.info(" RelatedOrderedSetElementsAccessor.get"); - return OrderedSetUtils.toList(g, element); - } catch (DatabaseException e) { - throw new MappingException(e); - } - } - - @Override - public boolean set(WriteGraph g, Resource element, Collection value) - throws MappingException { - try { - LOGGER.info(" RelatedOrderedSetElementsAccessor.set"); - return OrderedSetUtils.set(g, element, value); - // FIXME Implement deleteExtraObjects - } catch (DatabaseException e) { - throw new MappingException(e); - } - - } - -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/domain/RelatedValueAccessor.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/domain/RelatedValueAccessor.java deleted file mode 100644 index 719011fa..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/domain/RelatedValueAccessor.java +++ /dev/null @@ -1,114 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2013 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.rules.domain; - -import java.util.Arrays; - -import org.apache.log4j.Logger; -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.Statement; -import org.simantics.db.WriteGraph; -import org.simantics.db.exception.DatabaseException; -import org.simantics.layer0.Layer0; -import org.simantics.objmap.exceptions.MappingException; - -/** - * Accesses a value attached to the element by given functional relation. - * @author Hannu Niemist� - */ -public class RelatedValueAccessor implements IDomainAccessor { - - static Logger LOGGER = Logger.getLogger("org.simantics.objmap"); - - Resource relation; - Resource valueType; - - public RelatedValueAccessor(Resource relation, Resource valueType) { - this.relation = relation; - this.valueType = valueType; - } - - @Override - public Object get(ReadGraph g, Resource element) throws MappingException { - try { - LOGGER.info(" RelatedValueAccessor.get"); - Resource valueResource = g.getPossibleObject(element, relation); - if(valueResource == null) - return null; - return g.getValue(valueResource); - } catch (DatabaseException e) { - throw new MappingException(e); - } - } - - @Override - public boolean set(WriteGraph g, Resource element, Object value) - throws MappingException { - try { - LOGGER.info(" RelatedValueAccessor.set"); - Statement valueStatement = g.getPossibleStatement(element, relation); - if(valueStatement == null) { - if(value == null) - return false; - Resource valueResource = g.newResource(); - g.claim(valueResource, Layer0.getInstance(g).InstanceOf, null, - valueType); - g.claim(element, relation, valueResource); - g.claimValue(valueResource, value); - return true; - } - else { - if(value == null) { - if (!valueStatement.isAsserted(element)) { - g.deny(valueStatement.getObject()); - return true; - } else { - return false; - } - } - Object currentValue = g.getValue(valueStatement.getObject()); - if(equals(currentValue,value)) - return false; - if (!valueStatement.isAsserted(element)) - g.claimValue(valueStatement.getObject(), value); - else { - Resource valueResource = g.newResource(); - g.claim(valueResource, Layer0.getInstance(g).InstanceOf, null, - valueType); - g.claim(element, relation, valueResource); - g.claimValue(valueResource, value); - } - return true; - } - } catch (DatabaseException e) { - throw new MappingException(e); - } - - } - - private boolean equals(Object o1, Object o2) { - if (o1 instanceof boolean[]) - Arrays.equals((boolean[])o1,(boolean[])o2); - if (o1 instanceof int[]) - Arrays.equals((int[])o1,(int[])o2); - if (o1 instanceof float[]) - Arrays.equals((float[])o1,(float[])o2); - if (o1 instanceof double[]) - Arrays.equals((double[])o1,(double[])o2); - if (o1 instanceof byte[]) - Arrays.equals((byte[])o1,(byte[])o2); - return o1.equals(o2); - - } - -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/factory/IClassRuleFactory.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/factory/IClassRuleFactory.java deleted file mode 100644 index ad9ca7bc..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/factory/IClassRuleFactory.java +++ /dev/null @@ -1,22 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2013 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.rules.factory; - -import java.lang.annotation.Annotation; - -import org.simantics.db.ReadGraph; -import org.simantics.db.exception.DatabaseException; -import org.simantics.objmap.bidirectional.IBidirectionalMappingRule; - -public interface IClassRuleFactory { - IBidirectionalMappingRule create(ReadGraph g, Annotation annotation, Class clazz) throws DatabaseException; -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/factory/ICollectionRuleFactory.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/factory/ICollectionRuleFactory.java deleted file mode 100644 index 5018e03c..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/factory/ICollectionRuleFactory.java +++ /dev/null @@ -1,25 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.rules.factory; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Method; - -import org.simantics.db.ReadGraph; -import org.simantics.db.exception.DatabaseException; -import org.simantics.objmap.bidirectional.IBidirectionalMappingRule; - -public interface ICollectionRuleFactory { - IBidirectionalMappingRule create(ReadGraph g, Annotation annotation, Method getter, Method adder, Method remover) throws DatabaseException; - boolean isAdder(Annotation getterAnnotation, Annotation annotation); - boolean isRemover(Annotation getterAnnotation, Annotation annotation); -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/factory/IFieldRuleFactory.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/factory/IFieldRuleFactory.java deleted file mode 100644 index 267273d3..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/factory/IFieldRuleFactory.java +++ /dev/null @@ -1,23 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2013 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.rules.factory; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Field; - -import org.simantics.db.ReadGraph; -import org.simantics.db.exception.DatabaseException; -import org.simantics.objmap.bidirectional.IBidirectionalMappingRule; - -public interface IFieldRuleFactory { - IBidirectionalMappingRule create(ReadGraph g, Annotation annotation, Field field) throws DatabaseException; -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/factory/IGetSetRuleFactory.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/factory/IGetSetRuleFactory.java deleted file mode 100644 index 5ed52def..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/factory/IGetSetRuleFactory.java +++ /dev/null @@ -1,24 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.rules.factory; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Method; - -import org.simantics.db.ReadGraph; -import org.simantics.db.exception.DatabaseException; -import org.simantics.objmap.bidirectional.IBidirectionalMappingRule; - -public interface IGetSetRuleFactory { - IBidirectionalMappingRule create(ReadGraph g, Annotation annotation, Method getter, Method setter) throws DatabaseException; - boolean isSetter(Annotation getterAnnotation, Annotation annotation); -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/factory/IMethodRuleFactory.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/factory/IMethodRuleFactory.java deleted file mode 100644 index 86acc7c8..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/factory/IMethodRuleFactory.java +++ /dev/null @@ -1,23 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2013 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.rules.factory; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Method; - -import org.simantics.db.ReadGraph; -import org.simantics.db.exception.DatabaseException; -import org.simantics.objmap.bidirectional.IBidirectionalMappingRule; - -public interface IMethodRuleFactory { - IBidirectionalMappingRule create(ReadGraph g, Annotation annotation, Method method) throws DatabaseException; -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/range/AdaptedRangeAccessor.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/range/AdaptedRangeAccessor.java deleted file mode 100644 index 3b6e0104..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/range/AdaptedRangeAccessor.java +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.rules.range; - -import org.simantics.objmap.exceptions.MappingException; -import org.simantics.objmap.graph.rules.adapters.ValueAdapter; - - - -public class AdaptedRangeAccessor implements IRangeAccessor { - IRangeAccessor baseAccessor; - ValueAdapter adapter; - - public AdaptedRangeAccessor(IRangeAccessor baseAccessror, - ValueAdapter adapter) { - this.baseAccessor = baseAccessror; - this.adapter = adapter; - } - - @Override - public Object get(Range element) throws MappingException { - return adapter.rangeToDomain(baseAccessor.get(element)); - } - - @Override - public boolean set(Range element, Object value) throws MappingException { - return baseAccessor.set(element, adapter.domainToRange(value)); - } -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/range/CollectionAccessor.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/range/CollectionAccessor.java deleted file mode 100644 index d2b9f837..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/range/CollectionAccessor.java +++ /dev/null @@ -1,91 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.rules.range; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.Collection; - -import org.simantics.objmap.exceptions.MappingException; - - -/** - * Accessor for mapped collections. - * Uses three methods: - * - Getter: returns the collection. - * - Adder: adds one item into the collection. - * - Remover: removes one item from the collection. - * - * @author Marko Luukkainen - * - * @param - */ -public class CollectionAccessor implements IRangeAccessor> { - - private Method getter; - private Method adder; - private Method remover; - - public CollectionAccessor(Method getter, Method adder, Method remover) { - this.getter = getter; - this.adder = adder; - this.remover = remover; - } - - @SuppressWarnings("unchecked") - public java.util.Collection get(Object element) throws MappingException { - try { - return (Collection) getter.invoke(element); - } catch (IllegalArgumentException e) { - throw new MappingException(e); - } catch (IllegalAccessException e) { - throw new MappingException(e); - } catch (InvocationTargetException e) { - throw new MappingException(e.getCause()); - } - }; - - @Override - public boolean set(Range element, Collection value) - throws MappingException { - java.util.Collection current = get(element); - Collection adding = new ArrayList(); - Collection removing = new ArrayList(); - for (T e : current) { - if (!value.contains(e)) - removing.add(e); - } - for (T e : value) { - if (!current.contains(e)) - adding.add(e); - } - - try { - for (T e : removing) { - remover.invoke(element, e); - } - - for (T e : adding) { - adder.invoke(element, e); - } - } catch (IllegalArgumentException e) { - throw new MappingException(e); - } catch (IllegalAccessException e) { - throw new MappingException(e); - } catch (InvocationTargetException e) { - throw new MappingException(e.getCause()); - } - return removing.size() > 0 || adding.size() > 0; - - } -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/range/CompoundGetSetValueAccessor.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/range/CompoundGetSetValueAccessor.java deleted file mode 100644 index 7dac5f7f..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/range/CompoundGetSetValueAccessor.java +++ /dev/null @@ -1,84 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.rules.range; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - -import org.simantics.objmap.exceptions.MappingException; - - -/** - * Accessor for mapped value. Uses two methods: - * - Getter: returns the current value. - * - Setter: sets the current value. The value may be null. (if setter parameter is primitive, null value is not mapped). - * - * @author Marko Luukkainen - * - * @param - */ -public class CompoundGetSetValueAccessor implements IRangeAccessor { - - private Method getter; - private Method setter; - private boolean primitive; - - public CompoundGetSetValueAccessor(Method getter, Method setter) { - this.getter = getter; - this.setter = setter; - this.primitive = setter.getParameterTypes()[0].isPrimitive(); - } - - @SuppressWarnings("unchecked") - public T get(Range element) throws MappingException { - try { - return (T) getter.invoke(element); - } catch (IllegalArgumentException e) { - throw new MappingException(e); - } catch (IllegalAccessException e) { - throw new MappingException(e); - } catch (InvocationTargetException e) { - throw new MappingException(e.getCause()); - } - }; - - @Override - public boolean set(Range element, T value) - throws MappingException { - if (value == null && primitive) - return false; - if (equal(get(element),value)) - return false; - try { - setter.invoke(element, value); - } catch (IllegalArgumentException e) { - throw new MappingException(e); - } catch (IllegalAccessException e) { - throw new MappingException(e); - } catch (InvocationTargetException e) { - throw new MappingException(e.getCause()); - } - return true; - - } - - private boolean equal(Object v1, Object v2) { - if (v1 == null) { - if (v2 == null) - return true; - return false; - } else if (v2 == null) { - return false; - } - return v1.equals(v2); - } -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/range/FieldAccessor.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/range/FieldAccessor.java deleted file mode 100644 index 4cd0f2e5..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/range/FieldAccessor.java +++ /dev/null @@ -1,76 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2013 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.rules.range; - -import java.lang.reflect.Field; - -import org.apache.log4j.Logger; -import org.simantics.objmap.exceptions.MappingException; - - -/** - * Accesses the given field of the element. - * @author Hannu Niemistö - */ -public class FieldAccessor implements IRangeAccessor { - - static Logger LOGGER = Logger.getLogger("org.simantics.objmap"); - - Field field; - - public FieldAccessor(Field field) { - this.field = field; - } - - @Override - public T get(Range element) throws MappingException { - try { - @SuppressWarnings("unchecked") - T result = (T)field.get(element); - - if(LOGGER.isInfoEnabled()) - LOGGER.info(" FieldAccessor.get " + - field.getName() + " -> " + result - ); - - return result; - } catch (IllegalArgumentException e) { - throw new MappingException(e); - } catch (IllegalAccessException e) { - throw new MappingException(e); - } - } - - @Override - public boolean set(Range element, T value) throws MappingException { - try { - Object currentValue = field.get(element); - - if(LOGGER.isInfoEnabled()) - LOGGER.info(" FieldAccessor.set " + - field.getName() + " " + currentValue + - " -> " + value - ); - - if(value == null - ? (currentValue == null || field.getType().isPrimitive()) - : value.equals(currentValue)) - return false; - field.set(element, value); - return true; - } catch (IllegalArgumentException e) { - throw new MappingException(e); - } catch (IllegalAccessException e) { - throw new MappingException(e); - } - } -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/range/FieldAccessorWithDefault.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/range/FieldAccessorWithDefault.java deleted file mode 100644 index dea8cf35..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/range/FieldAccessorWithDefault.java +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2013 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.rules.range; - -import java.lang.reflect.Field; - -import org.simantics.objmap.exceptions.MappingException; - - -/** - * Accesses the given field of the element. - * @author Hannu Niemist� - */ -public class FieldAccessorWithDefault extends FieldAccessor { - - T defaultValue; - - public FieldAccessorWithDefault(Field field, T defaultValue) { - super(field); - this.defaultValue = defaultValue; - } - - @Override - public T get(Range element) throws MappingException { - T value = super.get(element); - if(value == null) - return defaultValue; - else - return value; - } -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/range/GetSetObjectAccessor.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/range/GetSetObjectAccessor.java deleted file mode 100644 index befd2fda..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/range/GetSetObjectAccessor.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.rules.range; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - -import org.simantics.objmap.exceptions.MappingException; - - -/** - * Accessor for mapped objects. Uses two methods: - * - Getter: returns the current object. - * - Setter: sets the current object. The object may be null. - * - * @author Marko Luukkainen - * - * @param - */ -public class GetSetObjectAccessor implements IRangeAccessor { - - private Method getter; - private Method setter; - - - public GetSetObjectAccessor(Method getter, Method setter) { - this.getter = getter; - this.setter = setter; - - } - - @SuppressWarnings("unchecked") - public T get(Range element) throws MappingException { - try { - return (T) getter.invoke(element); - } catch (IllegalArgumentException e) { - throw new MappingException(e); - } catch (IllegalAccessException e) { - throw new MappingException(e); - } catch (InvocationTargetException e) { - throw new MappingException(e.getCause()); - } - }; - - @Override - public boolean set(Range element, T value) - throws MappingException { - try { - setter.invoke(element, value); - } catch (IllegalArgumentException e) { - throw new MappingException(e); - } catch (IllegalAccessException e) { - throw new MappingException(e); - } catch (InvocationTargetException e) { - throw new MappingException(e.getCause()); - } - return true; - - } -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/range/GetSetValueAccessor.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/range/GetSetValueAccessor.java deleted file mode 100644 index 9f17e781..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/range/GetSetValueAccessor.java +++ /dev/null @@ -1,84 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.rules.range; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - -import org.simantics.objmap.exceptions.MappingException; - - -/** - * Accessor for mapped value. Uses two methods: - * - Getter: returns the current value. - * - Setter: sets the current value. The value may be null. (if setter parameter is primitive, null value is not mapped). - * - * @author Marko Luukkainen - * - * @param - */ -public class GetSetValueAccessor implements IRangeAccessor { - - private Method getter; - private Method setter; - private boolean primitive; - - public GetSetValueAccessor(Method getter, Method setter) { - this.getter = getter; - this.setter = setter; - this.primitive = setter.getParameterTypes()[0].isPrimitive(); - } - - @SuppressWarnings("unchecked") - public T get(Range element) throws MappingException { - try { - return (T) getter.invoke(element); - } catch (IllegalArgumentException e) { - throw new MappingException(e); - } catch (IllegalAccessException e) { - throw new MappingException(e); - } catch (InvocationTargetException e) { - throw new MappingException(e.getCause()); - } - }; - - @Override - public boolean set(Range element, T value) - throws MappingException { - if (value == null && primitive) - return false; - if (equal(get(element),value)) - return false; - try { - setter.invoke(element, value); - } catch (IllegalArgumentException e) { - throw new MappingException(e); - } catch (IllegalAccessException e) { - throw new MappingException(e); - } catch (InvocationTargetException e) { - throw new MappingException(e.getCause()); - } - return true; - - } - - private boolean equal(Object v1, Object v2) { - if (v1 == null) { - if (v2 == null) - return true; - return false; - } else if (v2 == null) { - return false; - } - return v1.equals(v2); - } -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/range/IRangeAccessor.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/range/IRangeAccessor.java deleted file mode 100644 index 94e7fcac..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/range/IRangeAccessor.java +++ /dev/null @@ -1,25 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2013 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.rules.range; - -import org.simantics.objmap.exceptions.MappingException; - - - -/** - * Provides access to some property of range elements. - * @author Hannu Niemistö - */ -public interface IRangeAccessor { - T get(Range element) throws MappingException; - boolean set(Range element, T value) throws MappingException; -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/range/ListAccessor.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/range/ListAccessor.java deleted file mode 100644 index a384235b..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/range/ListAccessor.java +++ /dev/null @@ -1,94 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.rules.range; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.Collection; - -import org.simantics.objmap.exceptions.MappingException; -import org.simantics.utils.datastructures.Pair; - - -/** - * Accessor for mapped collections. - * Uses three methods: - * - Getter: returns the collection. - * - Adder: adds one item into the collection. - * - Remover: removes one item from the collection. - * - * @author Marko Luukkainen - * - * @param - */ -public class ListAccessor implements IRangeAccessor> { - - private Method getter; - private Method adder; - private Method remover; - - public ListAccessor(Method getter, Method adder, Method remover) { - this.getter = getter; - this.adder = adder; - this.remover = remover; - } - - @SuppressWarnings("unchecked") - public java.util.Collection get(Object element) throws MappingException { - try { - return (Collection) getter.invoke(element); - } catch (IllegalArgumentException e) { - throw new MappingException(e); - } catch (IllegalAccessException e) { - throw new MappingException(e); - } catch (InvocationTargetException e) { - throw new MappingException(e.getCause()); - } - }; - - @Override - public boolean set(Range element, Collection value) - throws MappingException { - java.util.Collection current = get(element); - Collection> adding = new ArrayList>(); - Collection removing = new ArrayList(); - for (T e : current) { - if (!value.contains(e)) - removing.add(e); - } - int i = 0; - for (T e : value) { - if (!current.contains(e)) - adding.add(new Pair(i, e)); - i++; - } - - try { - for (T e : removing) { - remover.invoke(element, e); - } - - for (Pair e : adding) { - adder.invoke(element, e.first,e.second); - } - } catch (IllegalArgumentException e) { - throw new MappingException(e); - } catch (IllegalAccessException e) { - throw new MappingException(e); - } catch (InvocationTargetException e) { - throw new MappingException(e.getCause()); - } - return removing.size() > 0 || adding.size() > 0; - - } -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/schema/AdaptedLinkType.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/schema/AdaptedLinkType.java deleted file mode 100644 index d66e4f1b..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/schema/AdaptedLinkType.java +++ /dev/null @@ -1,87 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.schema; - -//import org.apache.log4j.Logger; -import org.eclipse.core.runtime.IAdaptable; -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.WriteGraph; -import org.simantics.db.exception.DatabaseException; - -import org.simantics.objmap.backward.IBackwardMapping; -import org.simantics.objmap.exceptions.MappingException; -import org.simantics.objmap.forward.IForwardMapping; - -/** - * A link type that is associated with adaptable resource (ReadGraph.getAdapter(Resource,Class)). - * The adapted object must implement IAdaptable interface for returning the original Resource. - * - * @author Marko Luukkainen - * - */ -public class AdaptedLinkType implements ILinkType { - - - //static Logger LOGGER = Logger.getLogger("org.simantics.objmap"); - - Resource domainType; - Class rangeType; - - - public AdaptedLinkType(Resource domainType, Class rangeType) { - this.domainType = domainType; - this.rangeType = rangeType; - } - - @Override - public Resource createDomainElement(WriteGraph g, Range rangeElement) - throws MappingException { - try { - IAdaptable adaptable = (IAdaptable)rangeElement; - Resource res = (Resource)adaptable.getAdapter(Resource.class); - if (res == null) - throw new NullPointerException(); - return res; - } catch (Exception e) { - throw new MappingException("Adapted object must implement IAdaptable interface to return the source Resource.", e); - } - - } - - @SuppressWarnings("unchecked") - @Override - public Range createRangeElement(ReadGraph g, Resource domainElement) - throws MappingException { - try { - return (Range)g.adapt(domainElement, rangeType); - } catch (DatabaseException e) { - throw new MappingException(e); - } - } - - public void createDomain(WriteGraph graph, IBackwardMapping mapping, Resource domainElement, Range rangeElement) throws MappingException { - - }; - - public void createRange(ReadGraph graph, org.simantics.objmap.forward.IForwardMapping mapping, Resource domainElement, Range rangeElement) throws MappingException { - - }; - - public boolean updateDomain(WriteGraph g, IBackwardMapping map, Resource domainElement, Range rangeElement) throws MappingException { - return false; - } - - public boolean updateRange(ReadGraph g, IForwardMapping map, Resource domainElement, Range rangeElement) throws MappingException { - return false; - } -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/schema/DefaultSchema.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/schema/DefaultSchema.java deleted file mode 100644 index e5adac84..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/schema/DefaultSchema.java +++ /dev/null @@ -1,98 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2013 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.schema; - - - -import gnu.trove.map.hash.THashMap; - -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.common.utils.NameUtils; -import org.simantics.db.exception.DatabaseException; -import org.simantics.objmap.exceptions.MappingException; - - -/** - * - */ -public class DefaultSchema implements IMappingSchema { - - THashMap> domainLinkTypes = - new THashMap>(); - THashMap, ILinkType> rangeLinkTypes = - new THashMap, ILinkType>(); - - public void addLinkType(SimpleLinkType linkType) { - domainLinkTypes.put(linkType.domainType, linkType); - rangeLinkTypes.put(linkType.rangeType, linkType); - } - - public void addLinkType(AdaptedLinkType linkType) { - domainLinkTypes.put(linkType.domainType, linkType); - rangeLinkTypes.put(linkType.rangeType, linkType); - } - - @Override - public ILinkType linkTypeOfDomainElement(ReadGraph g, Resource element) throws MappingException { - try { - - for(Resource type : g.getTypes(element)) { - - ILinkType linkType = domainLinkTypes.get(type); - if(linkType != null) return linkType; - - } - - throw new MappingException("Didn't find a link type for " + - NameUtils.getSafeName(g, element) + "."); - - } catch (DatabaseException e) { - throw new MappingException(e); - } - } - - @Override - public ILinkType linkTypeOfRangeElement(Object element) throws MappingException { - ILinkType type = rangeLinkTypes.get(element.getClass()); - if(type == null) { - for (Class clazz : element.getClass().getInterfaces()) { - type = rangeLinkTypes.get(clazz); - if (type != null) - return type; - - } - throw new MappingException("Didn't find a link type for " + element + "."); - } - return type; - } - - - public ILinkType linkTypeOfDomainType(ReadGraph g, Resource type) { - return domainLinkTypes.get(type); - } - - public ILinkType linkTypeOfRangeType(Class clazz) { - ILinkType type = rangeLinkTypes.get(clazz); - if(type == null) { - // FIXME: c is not referenced at all, should it be? - // TODO: should this method take inheritance into account ? - for (Class c : clazz.getInterfaces()) { - type = rangeLinkTypes.get(clazz); - if (type != null) - return type; - - } - } - return null; - } -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/schema/DynamicSimpleLinkType.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/schema/DynamicSimpleLinkType.java deleted file mode 100644 index 0abd423c..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/schema/DynamicSimpleLinkType.java +++ /dev/null @@ -1,124 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.schema; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.ArrayList; - -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.WriteGraph; -import org.simantics.db.common.utils.NameUtils; -import org.simantics.db.exception.DatabaseException; -import org.simantics.layer0.Layer0; -import org.simantics.objmap.bidirectional.IBidirectionalMappingRule; -import org.simantics.objmap.exceptions.MappingException; -import org.simantics.objmap.graph.annotations.GetType; -import org.simantics.objmap.graph.annotations.SetType; - -public class DynamicSimpleLinkType extends SimpleLinkType{ - - protected Method typeGetter; - protected Method typeSetter; - - public DynamicSimpleLinkType(Resource domainType, Class rangeType, ArrayList> rules) { - super(domainType, rangeType, rules); - findTypeGetter(rangeType); - } - - public DynamicSimpleLinkType(Resource domainType, Class rangeType) { - super(domainType, rangeType); - findTypeGetter(rangeType); - } - - private void findTypeGetter(Class clazz) { - for (Method m : clazz.getDeclaredMethods()) { - m.setAccessible(true); - GetType t = m.getAnnotation(GetType.class); - if (t != null) { - typeGetter = m; - } - SetType t2 = m.getAnnotation(SetType.class); - if (t2 != null) { - typeSetter = m; - } - } - if (typeGetter == null || typeSetter == null) { - Class superClazz = clazz.getSuperclass(); - if (superClazz != Object.class) - findTypeGetter(superClazz); - if (typeGetter == null || typeSetter == null) { - throw new RuntimeException("Cannot find dynamic type methods for class " + clazz.getSimpleName()); - } - } - - - } - - @Override - public Resource createDomainElement(WriteGraph g, Range rangeElement) - throws MappingException { - try { - String typeUri = (String)typeGetter.invoke(rangeElement, (Object[]) null); - if(LOGGER.isInfoEnabled()) - LOGGER.info("SimpleLinkType.createDomainElement " + - rangeElement.toString() - ); - Resource actualDomainType = g.getResource(typeUri); - Resource result = g.newResource(); - //g.claim(result, Layer0.getInstance(g).InstanceOf, null, domainType); - g.claim(result, Layer0.getInstance(g).InstanceOf, null, actualDomainType); - return result; - } catch(DatabaseException e) { - throw new MappingException(e); - } catch (IllegalArgumentException e) { - throw new MappingException(e); - } catch (IllegalAccessException e) { - throw new MappingException(e); - } catch (InvocationTargetException e) { - throw new MappingException(e.getCause()); - } - } - - @SuppressWarnings("unchecked") - @Override - public Range createRangeElement(ReadGraph g, Resource domainElement) - throws MappingException { - try { - if(LOGGER.isInfoEnabled()) - try { - LOGGER.info("SimpleLinkType.createRangeElement " + - NameUtils.getSafeName(g, domainElement) - ); - } catch(DatabaseException e) { - throw new MappingException(e); - } - Range r = (Range)rangeType.newInstance(); - Resource type = g.getSingleType(domainElement, domainType); - String uri = g.getURI(type); - typeSetter.invoke(r, uri); - return r; - } catch (InstantiationException e) { - throw new MappingException(e); - } catch (IllegalAccessException e) { - throw new MappingException(e); - } catch (DatabaseException e) { - throw new MappingException(e); - } catch (IllegalArgumentException e) { - throw new MappingException(e); - } catch (InvocationTargetException e) { - throw new MappingException(e.getCause()); - } - } - -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/schema/ILinkType.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/schema/ILinkType.java deleted file mode 100644 index ca5036de..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/schema/ILinkType.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2013 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.schema; - -import org.simantics.objmap.backward.IBackwardLinkType; -import org.simantics.objmap.bidirectional.IBidirectionalMappingRule; -import org.simantics.objmap.forward.IForwardLinkType; - -/** - * Contains rules for how a link should be created and maintained. - * @author Hannu Niemistö - */ -public interface ILinkType extends IBidirectionalMappingRule, IBackwardLinkType, IForwardLinkType { - /** - * Creates a domain element based on known range element. - */ - //Resource createDomainElement(WriteGraph g, Object rangeElement) throws MappingException; - - /** - * Creates a range element based on known domain element. - */ - //Object createRangeElement(ReadGraph g, Resource domainElement) throws MappingException; -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/schema/IMappingSchema.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/schema/IMappingSchema.java deleted file mode 100644 index 884f006f..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/schema/IMappingSchema.java +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2013 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.schema; - -import org.simantics.db.ReadGraph; -import org.simantics.objmap.exceptions.MappingException; - -/** - * Specifies the link types of new elements added to a mapping. - * @author Hannu Niemistö - */ -public interface IMappingSchema { - /** - * @return Link type that should be used for the element. - */ - ILinkType linkTypeOfDomainElement(ReadGraph g, Domain element) throws MappingException; - - /** - * @return Link type that should be used for the element. - */ - ILinkType linkTypeOfRangeElement(Range element) throws MappingException; -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/schema/MappingSchemas.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/schema/MappingSchemas.java deleted file mode 100644 index b863fbad..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/schema/MappingSchemas.java +++ /dev/null @@ -1,261 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.schema; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.Collection; - -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.exception.DatabaseException; -import org.simantics.objmap.bidirectional.IBidirectionalMappingRule; -import org.simantics.objmap.graph.annotations.CompoundRelatedGetValue; -import org.simantics.objmap.graph.annotations.DynamicGraphType; -import org.simantics.objmap.graph.annotations.GraphType; -import org.simantics.objmap.graph.annotations.HasCollectionAdder; -import org.simantics.objmap.graph.annotations.HasCollectionRemover; -import org.simantics.objmap.graph.annotations.HasSetter; -import org.simantics.objmap.graph.annotations.OptionalRelatedElements; -import org.simantics.objmap.graph.annotations.OrderedElementsGet; -import org.simantics.objmap.graph.annotations.OrderedSetType; -import org.simantics.objmap.graph.annotations.RelatedElements; -import org.simantics.objmap.graph.annotations.RelatedElementsGet; -import org.simantics.objmap.graph.annotations.RelatedGetObj; -import org.simantics.objmap.graph.annotations.RelatedGetValue; -import org.simantics.objmap.graph.annotations.RelatedOrderedSetElements; -import org.simantics.objmap.graph.annotations.RelatedValue; -import org.simantics.objmap.graph.annotations.UpdateMethod; -import org.simantics.objmap.graph.annotations.factories.CompoundRelatedGetSetValueRuleFactory; -import org.simantics.objmap.graph.annotations.factories.OptionalRelatedElementsRuleFactory; -import org.simantics.objmap.graph.annotations.factories.OrderedElementsRuleFactory; -import org.simantics.objmap.graph.annotations.factories.RelatedElementsRuleFactory; -import org.simantics.objmap.graph.annotations.factories.RelatedElementsRuleFactory2; -import org.simantics.objmap.graph.annotations.factories.RelatedGetSetObjRuleFactory; -import org.simantics.objmap.graph.annotations.factories.RelatedGetSetValueRuleFactory; -import org.simantics.objmap.graph.annotations.factories.RelatedOrderedSetElementsRuleFactory; -import org.simantics.objmap.graph.annotations.factories.RelatedValueRuleFactory; -import org.simantics.objmap.graph.annotations.factories.UpdateMethodFactory; -import org.simantics.objmap.graph.annotations.meta.IsClassRule; -import org.simantics.objmap.graph.annotations.meta.IsCollectionRule; -import org.simantics.objmap.graph.annotations.meta.IsFieldRule; -import org.simantics.objmap.graph.annotations.meta.IsGetSetRule; -import org.simantics.objmap.graph.annotations.meta.IsMethodRule; -import org.simantics.objmap.graph.rules.factory.IClassRuleFactory; -import org.simantics.objmap.graph.rules.factory.ICollectionRuleFactory; -import org.simantics.objmap.graph.rules.factory.IFieldRuleFactory; -import org.simantics.objmap.graph.rules.factory.IGetSetRuleFactory; -import org.simantics.objmap.graph.rules.factory.IMethodRuleFactory; - - -public class MappingSchemas { - /** - * Creates a new SimpleLinkType based on the annotations in the given class. - * @throws IllegalAccessException - * @throws InstantiationException - * @see GraphType - * @see RelatedValue - */ - public static SimpleLinkType fromAnnotations(ReadGraph g, Class clazz) throws DatabaseException, InstantiationException, IllegalAccessException { - GraphType graphType = clazz.getAnnotation(GraphType.class); - - if (graphType != null) { - ArrayList> rules = new ArrayList>(); - collectRulesFromAnnotations(g, clazz, rules); - - return new SimpleLinkType(g.getResource(graphType.value()), clazz, rules); - } - DynamicGraphType dynamicType = clazz.getAnnotation(DynamicGraphType.class); - if (dynamicType != null) { - ArrayList> rules = new ArrayList>(); - collectRulesFromAnnotations(g, clazz, rules); - - return new DynamicSimpleLinkType(g.getResource(dynamicType.value()), clazz, rules); - } - OrderedSetType orderedSetType = clazz.getAnnotation(OrderedSetType.class); - if (orderedSetType != null) { - ArrayList> rules = new ArrayList>(); - collectRulesFromAnnotations(g, clazz, rules); - - return new OrderedSetSimpleLinkType(g.getResource(orderedSetType.value()), clazz, rules); - } - throw new IllegalArgumentException("Class " + clazz.toString() + " does not contain annotations."); - } - - public static void collectRulesFromAnnotations(ReadGraph g, Class clazz, Collection> rules) throws DatabaseException, InstantiationException, IllegalAccessException { - Class superclass = clazz.getSuperclass(); - if(superclass != null) - collectRulesFromAnnotations(g, superclass, rules); - - for(Annotation annotation : clazz.getAnnotations()) { - - IsClassRule tag = annotation.annotationType().getAnnotation(IsClassRule.class); - if(tag!= null) { - rules.add(createClassRule(g, annotation, clazz).create(g, annotation, clazz)); - } - } - - for(Field f : clazz.getDeclaredFields()) { - f.setAccessible(true); - - for(Annotation annotation : f.getAnnotations()) { - - IsFieldRule tag = annotation.annotationType().getAnnotation(IsFieldRule.class); - if(tag != null) { - rules.add(createFieldRule(g, annotation, f).create(g, annotation, f)); - } - } - } - - for(Method m : clazz.getDeclaredMethods()) { - m.setAccessible(true); - - for(Annotation annotation : m.getAnnotations()) { - IsMethodRule tag = - annotation.annotationType().getAnnotation(IsMethodRule.class); - if(tag != null) { - rules.add(createMethodRule(g, annotation, m).create(g, annotation, m)); - } - } - } - - for (Method m : clazz.getDeclaredMethods()) { - m.setAccessible(true); - for (Annotation annotation : m.getAnnotations()) { - Class annotationType = annotation.annotationType(); - - IsGetSetRule tag = - annotationType.getAnnotation(IsGetSetRule.class); - if (tag != null) { - - HasSetter setterAnnType = annotationType.getAnnotation(HasSetter.class); - - Class setterAnn = setterAnnType.value(); - - Method getter = m; - - IGetSetRuleFactory ruleFactory = createGetSetRuleFactory(g, annotation, getter); - - - Method setter = null; - - for (Method m2 : clazz.getDeclaredMethods()) { - Annotation set = m2.getAnnotation(setterAnn); - if (set != null && ruleFactory.isSetter(annotation, set)) - setter = m2; - } - - rules.add(ruleFactory.create(g, annotation, getter, setter)); - } - - } - } - - for (Method m : clazz.getDeclaredMethods()) { - m.setAccessible(true); - for (Annotation annotation : m.getAnnotations()) { - Class annotationType = annotation.annotationType(); - - IsCollectionRule tag = - annotationType.getAnnotation(IsCollectionRule.class); - if (tag != null) { - - HasCollectionAdder adderAnnType = annotationType.getAnnotation(HasCollectionAdder.class); - HasCollectionRemover removerAnnType = annotationType.getAnnotation(HasCollectionRemover.class); - - Class adderAnn = adderAnnType.value(); - Class removerAnn = removerAnnType.value(); - - Method getter = m; - - ICollectionRuleFactory ruleFactory = createCollectionRuleFactory(g, annotation, getter); - - - Method adder = null; - Method remover = null; - - for (Method m2 : clazz.getDeclaredMethods()) { - Annotation add = m2.getAnnotation(adderAnn); - Annotation rem = m2.getAnnotation(removerAnn); - if (add != null && ruleFactory.isAdder(annotation, add)) - adder = m2; - if (rem != null && ruleFactory.isRemover(annotation, rem)) - remover = m2; - } - - - - rules.add(ruleFactory.create(g, annotation, getter,adder,remover)); - } - - } - } - } - - public static IClassRuleFactory createClassRule(ReadGraph g, Annotation annotation, Class clazz) { - return null; - } - - public static IFieldRuleFactory createFieldRule(ReadGraph g, Annotation annotation, Field field) { - if (annotation.annotationType().equals(RelatedElements.class)) - return new RelatedElementsRuleFactory(); - if (annotation.annotationType().equals(RelatedValue.class)) - return new RelatedValueRuleFactory(); - if (annotation.annotationType().equals(OptionalRelatedElements.class)) - return new OptionalRelatedElementsRuleFactory(); - if (annotation.annotationType().equals(RelatedOrderedSetElements.class)) - return new RelatedOrderedSetElementsRuleFactory(); - return null; - } - - public static IMethodRuleFactory createMethodRule(ReadGraph g, Annotation annotation, Method m) { - if (annotation.annotationType().equals(UpdateMethod.class)) - return new UpdateMethodFactory(); - return null; - } - - public static IGetSetRuleFactory createGetSetRuleFactory(ReadGraph g, Annotation annotation, Method getter) { - if (annotation.annotationType().equals(RelatedGetValue.class)) - return new RelatedGetSetValueRuleFactory(); - if (annotation.annotationType().equals(RelatedGetObj.class)) - return new RelatedGetSetObjRuleFactory(); - if (annotation.annotationType().equals(CompoundRelatedGetValue.class)) - return new CompoundRelatedGetSetValueRuleFactory(); - return null; - } - - public static ICollectionRuleFactory createCollectionRuleFactory(ReadGraph g, Annotation annotation, Method getter) { - if (annotation.annotationType().equals(RelatedElementsGet.class)) - return new RelatedElementsRuleFactory2(); - if (annotation.annotationType().equals(OrderedElementsGet.class)) - return new OrderedElementsRuleFactory(); - return null; - } - - /** - * Creates a new SimpleLinkType based on the annotations in the given class. - * @throws IllegalAccessException - * @throws InstantiationException - * @see GraphType - * @see RelatedValue - */ - - public static AdaptedLinkType fromAdaptable(ReadGraph g, String type, Class clazz) throws DatabaseException, InstantiationException, IllegalAccessException { - - - return new AdaptedLinkType(g.getResource(type), clazz); - } - - -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/schema/OrderedSetSimpleLinkType.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/schema/OrderedSetSimpleLinkType.java deleted file mode 100644 index b9127458..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/schema/OrderedSetSimpleLinkType.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.simantics.objmap.graph.schema; - -import java.util.ArrayList; - -import org.simantics.db.Resource; -import org.simantics.db.common.utils.OrderedSetUtils; -import org.simantics.db.exception.DatabaseException; -import org.simantics.objmap.bidirectional.IBidirectionalMappingRule; -import org.simantics.objmap.exceptions.MappingException; - -public class OrderedSetSimpleLinkType extends SimpleLinkType { - - public OrderedSetSimpleLinkType(Resource domainType, Class rangeType, ArrayList> rules) { - super(domainType, rangeType, rules); - } - - public OrderedSetSimpleLinkType(Resource domainType, Class rangeType) { - super(domainType, rangeType); - } - - public Resource createDomainElement(org.simantics.db.WriteGraph g, Range rangeElement) throws org.simantics.objmap.exceptions.MappingException { - try { - if(LOGGER.isInfoEnabled()) - LOGGER.info("SimpleLinkType.createDomainElement " + - rangeElement.toString() - ); - Resource result = OrderedSetUtils.create(g, domainType); - return result; - } catch(DatabaseException e) { - throw new MappingException(e); - } - }; - -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/schema/SimpleLinkType.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/schema/SimpleLinkType.java deleted file mode 100644 index 880d117a..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/schema/SimpleLinkType.java +++ /dev/null @@ -1,140 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2013 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.schema; - -import java.util.ArrayList; - -import org.apache.log4j.Logger; -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.WriteGraph; -import org.simantics.db.common.utils.NameUtils; -import org.simantics.db.exception.DatabaseException; -import org.simantics.layer0.Layer0; -import org.simantics.objmap.backward.IBackwardMapping; -import org.simantics.objmap.bidirectional.IBidirectionalMappingRule; -import org.simantics.objmap.exceptions.MappingException; -import org.simantics.objmap.forward.IForwardMapping; - - -/** - * A link type that is associated with single domain and range type (class). - * SimpleLinkType is composed of simpler rules whose combination determines - * its update policy. - * @author Hannu Niemist� - */ -public class SimpleLinkType implements ILinkType { - - static Logger LOGGER = Logger.getLogger("org.simantics.objmap"); - - public Resource domainType; - public Class rangeType; - ArrayList> rules; - - public SimpleLinkType(Resource domainType, Class rangeType, - ArrayList> rules) { - this.domainType = domainType; - this.rangeType = rangeType; - this.rules = rules; - } - - public SimpleLinkType(Resource domainType, Class rangeType) { - this(domainType, rangeType, new ArrayList>()); - } - - /** - * Adds a new rule to this link type that is enforced - * during updates. - */ - public void addRule(IBidirectionalMappingRule rule) { - rules.add(rule); - } - - @Override - public Resource createDomainElement(WriteGraph g, Range rangeElement) - throws MappingException { - try { - if(LOGGER.isInfoEnabled()) - LOGGER.info("SimpleLinkType.createDomainElement " + - rangeElement.toString() - ); - Resource result = g.newResource(); - g.claim(result, Layer0.getInstance(g).InstanceOf, null, domainType); - return result; - } catch(DatabaseException e) { - throw new MappingException(e); - } - } - @SuppressWarnings("unchecked") - @Override - public Range createRangeElement(ReadGraph g, Resource domainElement) - throws MappingException { - try { - if(LOGGER.isInfoEnabled()) - try { - LOGGER.info("SimpleLinkType.createRangeElement " + - NameUtils.getSafeName(g, domainElement) - ); - } catch(DatabaseException e) { - throw new MappingException(e); - } - return (Range)rangeType.newInstance(); - } catch (InstantiationException e) { - throw new MappingException(e); - } catch (IllegalAccessException e) { - throw new MappingException(e); - } - } - - public void createDomain(WriteGraph graph, IBackwardMapping mapping, Resource domainElement, Range rangeElement) throws MappingException { - updateDomain(graph, mapping, domainElement, rangeElement); - }; - - public void createRange(ReadGraph graph, org.simantics.objmap.forward.IForwardMapping mapping, Resource domainElement, Range rangeElement) throws MappingException { - updateRange(graph, mapping, domainElement, rangeElement); - }; - - public boolean updateDomain(WriteGraph g, IBackwardMapping map, Resource domainElement, Range rangeElement) throws MappingException { - if(LOGGER.isInfoEnabled()) - try { - LOGGER.info("SimpleLinkType.updateDomain " + - NameUtils.getSafeName(g, domainElement) + " " + - rangeElement.toString() - ); - } catch(DatabaseException e) { - throw new MappingException(e); - } - - boolean updated = false; - for(IBidirectionalMappingRule rule : rules) - updated |= rule.updateDomain(g, map, domainElement, rangeElement); - return updated; - } - - public boolean updateRange(ReadGraph g, IForwardMapping map, Resource domainElement, Range rangeElement) throws MappingException { - - if(LOGGER.isInfoEnabled()) - try { - LOGGER.info("SimpleLinkType.updateRange " + - NameUtils.getSafeName(g, domainElement) + " " + - rangeElement.toString() - ); - } catch(DatabaseException e) { - throw new MappingException(e); - } - - boolean updated = false; - for(IBidirectionalMappingRule rule : rules) - updated |= rule.updateRange(g, map, domainElement, rangeElement); - return updated; - } -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/graph/schema/SimpleSchema.java b/org.simantics.objmap2/src/org/simantics/objmap/graph/schema/SimpleSchema.java deleted file mode 100644 index 734f101f..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/graph/schema/SimpleSchema.java +++ /dev/null @@ -1,94 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2013 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.schema; - - -import java.util.Stack; - -import gnu.trove.map.hash.THashMap; - -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.common.utils.NameUtils; -import org.simantics.db.exception.DatabaseException; -import org.simantics.objmap.exceptions.MappingException; - - -/** - * An implementation of IMappingSchema that contains - * only SimpleLinkTypes. The link type of any domain - * element is based solely on its type in database and - * the link type of any range element is based on its class. - * @author Hannu Niemistö - */ -public class SimpleSchema implements IMappingSchema { - - THashMap> domainLinkTypes = - new THashMap>(); - THashMap, ILinkType> rangeLinkTypes = - new THashMap, ILinkType>(); - - public void addLinkType(SimpleLinkType linkType) { - domainLinkTypes.put(linkType.domainType, linkType); - rangeLinkTypes.put(linkType.rangeType, linkType); - } - - public void addLinkType(AdaptedLinkType linkType) { - domainLinkTypes.put(linkType.domainType, linkType); - rangeLinkTypes.put(linkType.rangeType, linkType); - } - - @Override - public ILinkType linkTypeOfDomainElement(ReadGraph g, Resource element) throws MappingException { - try { - - for(Resource type : g.getTypes(element)) { - - ILinkType linkType = domainLinkTypes.get(type); - if(linkType != null) return linkType; - - } - - throw new MappingException("Didn't find a link type for " + NameUtils.getSafeName(g, element) + "."); - - } catch (DatabaseException e) { - throw new MappingException(e); - } - } - - @Override - public ILinkType linkTypeOfRangeElement(Object element) throws MappingException { - ILinkType type = rangeLinkTypes.get(element.getClass()); - if(type == null) { - Stack> clazzes = new Stack>(); - for (Class clazz : element.getClass().getInterfaces()) { - clazzes.add(clazz); - } - clazzes.add(element.getClass().getSuperclass()); - - - while (!clazzes.isEmpty()) { - Class clazz = clazzes.pop(); - - type = rangeLinkTypes.get(clazz); - if (type != null) - return type; - for (Class c : clazz.getInterfaces()) - clazzes.add(c); - - } - throw new MappingException("Didn't find a link type for " + element.getClass() + "."); - } - return type; - } - -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/internal/BidirectionalLink.java b/org.simantics.objmap2/src/org/simantics/objmap/internal/BidirectionalLink.java deleted file mode 100644 index 604de112..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/internal/BidirectionalLink.java +++ /dev/null @@ -1,30 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.internal; - -import org.simantics.objmap.bidirectional.IBidirectionalLinkType; - -public class BidirectionalLink { - IBidirectionalLinkType linkType; - Domain domainElement; - Range rangeElement; - - boolean domainModified; - boolean rangeModified; - - public BidirectionalLink(IBidirectionalLinkType linkType, - Domain domainElement, Range rangeElement) { - this.linkType = linkType; - this.domainElement = domainElement; - this.rangeElement = rangeElement; - } -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/internal/BidirectionalMapping.java b/org.simantics.objmap2/src/org/simantics/objmap/internal/BidirectionalMapping.java deleted file mode 100644 index 78615036..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/internal/BidirectionalMapping.java +++ /dev/null @@ -1,140 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.internal; - -import gnu.trove.map.hash.THashMap; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Set; - -import org.simantics.db.ReadGraph; -import org.simantics.db.WriteGraph; -import org.simantics.objmap.bidirectional.IBidirectionalLinkType; -import org.simantics.objmap.bidirectional.IBidirectionalMapping; -import org.simantics.objmap.bidirectional.IBidirectionalMappingSchema; -import org.simantics.objmap.exceptions.MappingException; - -public class BidirectionalMapping implements IBidirectionalMapping { - - IBidirectionalMappingSchema schema; - THashMap> forwardMap = - new THashMap>(); - THashMap> backwardMap = - new THashMap>(); - - ArrayList> modifiedDomain = new ArrayList>(); - ArrayList> modifiedRange = new ArrayList>(); - - private void markDomainModified(BidirectionalLink link) { - if(!link.domainModified) { - link.domainModified = true; - modifiedDomain.add(link); - } - } - - private void markRangeModified(BidirectionalLink link) { - if(!link.rangeModified) { - link.rangeModified = true; - modifiedRange.add(link); - } - } - - public BidirectionalMapping(IBidirectionalMappingSchema schema) { - this.schema = schema; - } - - private BidirectionalLink addLink(IBidirectionalLinkType linkType, Domain domainElement, Range rangeElement) { - BidirectionalLink link = - new BidirectionalLink(linkType, domainElement, rangeElement); - forwardMap.put(domainElement, link); - backwardMap.put(rangeElement, link); - return link; - } - - @Override - public Set getDomain() { - return Collections.unmodifiableSet(forwardMap.keySet()); - } - - @Override - public Range get(Domain domainElement) { - BidirectionalLink link = forwardMap.get(domainElement); - if(link == null) - return null; - return link.rangeElement; - } - - @Override - public Range map(ReadGraph graph, Domain domainElement) throws MappingException { - Range result = get(domainElement); - if(result == null) { - IBidirectionalLinkType linkType = - schema.linkTypeOfDomainElement(graph, domainElement); - Range rangeElement = linkType.createRangeElement(graph, domainElement); - addLink(linkType, domainElement, rangeElement); - linkType.createRange(graph, this, domainElement, rangeElement); - } - return result; - } - - public Collection updateRange(ReadGraph graph) throws MappingException { - ArrayList updated = new ArrayList(Math.max(10, modifiedDomain.size())); - for(BidirectionalLink link : modifiedDomain) { - link.domainModified = false; - if(link.linkType.updateRange(graph, this, link.domainElement, link.rangeElement)) - updated.add(link.rangeElement); - } - modifiedDomain.clear(); - return updated; - } - - @Override - public Set getRange() { - return Collections.unmodifiableSet(backwardMap.keySet()); - } - - @Override - public Domain inverseGet(Range rangeElement) { - BidirectionalLink link = backwardMap.get(rangeElement); - if(link == null) - return null; - return link.domainElement; - } - - @Override - public Domain inverseMap(WriteGraph graph, Range rangeElement) - throws MappingException { - Domain result = inverseGet(rangeElement); - if(result == null) { - IBidirectionalLinkType linkType = - schema.linkTypeOfRangeElement(graph, rangeElement); - Domain domainElement = linkType.createDomainElement(graph, rangeElement); - addLink(linkType, domainElement, rangeElement); - linkType.createDomain(graph, this, domainElement, rangeElement); - } - return result; - } - - public Collection updateDomain(WriteGraph graph) throws MappingException { - ArrayList updated = new ArrayList(Math.max(10, modifiedRange.size())); - for(BidirectionalLink link : modifiedRange) { - link.rangeModified = false; - if(link.linkType.updateDomain(graph, this, link.domainElement, link.rangeElement)) - updated.add(link.domainElement); - } - modifiedDomain.clear(); - return updated; - } - -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/internal/MonotoneBackwardMapping.java b/org.simantics.objmap2/src/org/simantics/objmap/internal/MonotoneBackwardMapping.java deleted file mode 100644 index 8205d1f3..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/internal/MonotoneBackwardMapping.java +++ /dev/null @@ -1,63 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.internal; - -import gnu.trove.map.hash.THashMap; - -import java.util.Collections; -import java.util.Set; - -import org.simantics.db.WriteGraph; -import org.simantics.objmap.backward.IBackwardLinkType; -import org.simantics.objmap.backward.IBackwardMapping; -import org.simantics.objmap.backward.IBackwardMappingSchema; -import org.simantics.objmap.exceptions.MappingException; - -/** - * An unidirectional (from range to domain) mapping that does not support removals. - * - * @author Hannu Niemistö - */ -public class MonotoneBackwardMapping implements IBackwardMapping { - - IBackwardMappingSchema schema; - THashMap map = new THashMap(); - - public MonotoneBackwardMapping(IBackwardMappingSchema schema) { - this.schema = schema; - } - - @Override - public Set getRange() { - return Collections.unmodifiableSet(map.keySet()); - } - - @Override - public Domain inverseGet(Range rangeElement) { - return map.get(rangeElement); - } - - @Override - public Domain inverseMap(WriteGraph graph, Range rangeElement) throws MappingException { - Domain result = inverseGet(rangeElement); - if(result == null) { - IBackwardLinkType linkType = - schema.linkTypeOfRangeElement(graph, rangeElement); - // Two phase creation makes cyclic references possible - Domain domainElement = linkType.createDomainElement(graph, rangeElement); - map.put(rangeElement, domainElement); - linkType.createDomain(graph, this, domainElement, rangeElement); - } - return result; - } - -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/internal/MonotoneForwardMapping.java b/org.simantics.objmap2/src/org/simantics/objmap/internal/MonotoneForwardMapping.java deleted file mode 100644 index 2f4f7a5d..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/internal/MonotoneForwardMapping.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.internal; - -import gnu.trove.map.hash.THashMap; - -import java.util.Collections; -import java.util.Set; - -import org.simantics.db.ReadGraph; -import org.simantics.objmap.exceptions.MappingException; -import org.simantics.objmap.forward.IForwardLinkType; -import org.simantics.objmap.forward.IForwardMapping; -import org.simantics.objmap.forward.IForwardMappingSchema; - -public class MonotoneForwardMapping implements IForwardMapping { - - IForwardMappingSchema schema; - THashMap map = new THashMap(); - - public MonotoneForwardMapping(IForwardMappingSchema schema) { - this.schema = schema; - } - - @Override - public Set getDomain() { - return Collections.unmodifiableSet(map.keySet()); - } - - @Override - public Range get(Domain domainElement) { - return map.get(domainElement); - } - - @Override - public Range map(ReadGraph graph, Domain domainElement) throws MappingException { - Range result = get(domainElement); - if(result == null) { - IForwardLinkType linkType = - schema.linkTypeOfDomainElement(graph, domainElement); - // Two phase creation makes cyclic references possible - Range rangeElement = linkType.createRangeElement(graph, domainElement); - map.put(domainElement, rangeElement); - linkType.createRange(graph, this, domainElement, rangeElement); - } - return result; - } - -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/structural/IStructuralObject.java b/org.simantics.objmap2/src/org/simantics/objmap/structural/IStructuralObject.java deleted file mode 100644 index 44340bf2..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/structural/IStructuralObject.java +++ /dev/null @@ -1,49 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.structural; - -import java.util.List; - -import org.simantics.db.Resource; - -/** - * Interface for structurally mapped Java objects. - * - * @author Marko Luukkainen - * - */ -public interface IStructuralObject { - - /** - * Context of an object. - * @return - */ - public List getContext(); - - /** - * Sets object's context. Used by ObjMap, don't touch. - * @param object - */ - public void setContext(List object); - - /** - * Return type resource for Structural instances. For other objects returns null. - * @return - */ - public Resource getType(); - - /** - * Sets object's type. Used by ObjMap, don't touch. - * @param object - */ - public void setType(Resource type); -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/structural/StructuralResource.java b/org.simantics.objmap2/src/org/simantics/objmap/structural/StructuralResource.java deleted file mode 100644 index 857d0e4a..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/structural/StructuralResource.java +++ /dev/null @@ -1,167 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.structural; - -import java.util.ArrayList; -import java.util.List; - -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.exception.DatabaseException; -import org.simantics.layer0.Layer0; - -/** - * An object representing structural Resource. - * - * - * @author Marko Luukkainen - * - */ -public class StructuralResource { - - private Resource resource; - private List context = new ArrayList(1); - - private Resource typeResource = null; - - public StructuralResource(Resource resource) { - assert(resource != null); - this.resource = resource; - } - public StructuralResource(ReadGraph g, Resource resource, Resource context) throws DatabaseException { - assert(resource != null); - this.resource = resource; - this.context.add(context); - resolveType(g); - } - - public StructuralResource(ReadGraph g, Resource resource, Resource... context) throws DatabaseException { - assert(resource != null); - this.resource = resource; - for (Resource r : context) - this.context.add(r); - resolveType(g); - } - - public StructuralResource(ReadGraph g, Resource resource, List context) throws DatabaseException { - assert(resource != null); - this.resource = resource; - for (Resource r : context) - this.context.add(r); - resolveType(g); - } - public StructuralResource(ReadGraph g, Resource resource, List context, Resource context2) throws DatabaseException { - assert(resource != null); - this.resource = resource; - for (Resource r : context) - this.context.add(r); - this.context.add(context2); - resolveType(g); - } - - private void resolveType(ReadGraph g) throws DatabaseException { - if (this.context.contains(resource)) { - Layer0 l0 = Layer0.getInstance(g); - typeResource = g.getSingleObject(resource, l0.InstanceOf); - } - } - - - /** - * The Resource in the DB. - * @return - */ - public Resource getResource() { - return resource; - } - - /** - * Context in which this resource is accessed. Each context resource represents a structural model instance. - * @return - */ - public List getContext() { - return context; - } - - /** - * If the resource is structural model instance, this returns the type Resource. Otherwise returns null. - * @return - */ - public Resource getTypeResource() { - return typeResource; - } - - /** - * Returns true, if the resource is structural, - * @return - */ - public boolean isStructural() { - return context.size() > 0; - } - - /** - * Returns true is the Resource is root of Structural Model instance. - * In this case the resource instance is editable. - * - * @return - */ - public boolean isStructuralRoot() { - return (context.size() == 1 && context.get(0).equals(resource)); - } - - /** - * Returns true, the resource is structural model instance. - * @return - */ - public boolean isStructuralInstance() { - return typeResource != null; - } - - @Override - public int hashCode() { - int hashCode = resource.hashCode(); - for (Resource ctx : context) - hashCode += ctx.hashCode(); - return hashCode; - } - - @Override - public boolean equals(Object obj) { - if (obj == this) - return true; - if (obj == null) - return false; - if (obj.getClass() != getClass()) - return false; - StructuralResource other = (StructuralResource)obj; - if (!resource.equals(other.resource)) - return false; - if (context.size() != other.context.size()) - return false; - for (int i = 0; i < context.size(); i++) { - if (!context.get(i).equals(other.context.get(i))) - return false; - } - return true; - } - - @Override - public String toString() { - String s = "Res: " + resource + " Context:"; - for (Resource ctx : context) - s+= " "+ ctx; - if (typeResource != null) - s+= " Type: " + typeResource; - return s; - } - -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/StructuralRelatedElementsAdd.java b/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/StructuralRelatedElementsAdd.java deleted file mode 100644 index ce4e62d8..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/StructuralRelatedElementsAdd.java +++ /dev/null @@ -1,23 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.structural.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) -public @interface StructuralRelatedElementsAdd { - String value(); -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/StructuralRelatedElementsGet.java b/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/StructuralRelatedElementsGet.java deleted file mode 100644 index ba0c7c1d..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/StructuralRelatedElementsGet.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.structural.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import org.simantics.objmap.graph.annotations.HasCollectionAdder; -import org.simantics.objmap.graph.annotations.HasCollectionRemover; -import org.simantics.objmap.graph.annotations.meta.IsCollectionRule; - - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) -@IsCollectionRule -@HasCollectionAdder(StructuralRelatedElementsAdd.class) -@HasCollectionRemover(StructuralRelatedElementsRem.class) -public @interface StructuralRelatedElementsGet { - String value(); - boolean composition() default false; -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/StructuralRelatedElementsRem.java b/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/StructuralRelatedElementsRem.java deleted file mode 100644 index 5823672d..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/StructuralRelatedElementsRem.java +++ /dev/null @@ -1,24 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.structural.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) -public @interface StructuralRelatedElementsRem { - String value(); -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/StructuralRelatedGetObj.java b/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/StructuralRelatedGetObj.java deleted file mode 100644 index 56e7a6b2..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/StructuralRelatedGetObj.java +++ /dev/null @@ -1,30 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.structural.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import org.simantics.objmap.graph.annotations.HasSetter; -import org.simantics.objmap.graph.annotations.meta.IsGetSetRule; - - - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) -@IsGetSetRule -@HasSetter(StructuralRelatedSetObj.class) -public @interface StructuralRelatedGetObj { - String value(); -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/StructuralRelatedSetObj.java b/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/StructuralRelatedSetObj.java deleted file mode 100644 index bae77b79..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/StructuralRelatedSetObj.java +++ /dev/null @@ -1,24 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.structural.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) -public @interface StructuralRelatedSetObj { - String value(); -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/TypeRelatedElementsAdd.java b/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/TypeRelatedElementsAdd.java deleted file mode 100644 index ffc5bbb7..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/TypeRelatedElementsAdd.java +++ /dev/null @@ -1,23 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.structural.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) -public @interface TypeRelatedElementsAdd { - String value(); -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/TypeRelatedElementsGet.java b/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/TypeRelatedElementsGet.java deleted file mode 100644 index 7c06d611..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/TypeRelatedElementsGet.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.structural.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import org.simantics.objmap.graph.annotations.HasCollectionAdder; -import org.simantics.objmap.graph.annotations.HasCollectionRemover; -import org.simantics.objmap.graph.annotations.meta.IsCollectionRule; - - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) -@IsCollectionRule -@HasCollectionAdder(TypeRelatedElementsAdd.class) -@HasCollectionRemover(TypeRelatedElementsRem.class) -public @interface TypeRelatedElementsGet { - String value(); - boolean composition() default false; -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/TypeRelatedElementsRem.java b/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/TypeRelatedElementsRem.java deleted file mode 100644 index c540bf5d..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/TypeRelatedElementsRem.java +++ /dev/null @@ -1,24 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.structural.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) -public @interface TypeRelatedElementsRem { - String value(); -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/TypeRelatedGetObj.java b/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/TypeRelatedGetObj.java deleted file mode 100644 index 63867300..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/TypeRelatedGetObj.java +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.structural.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import org.simantics.objmap.graph.annotations.HasSetter; -import org.simantics.objmap.graph.annotations.meta.IsGetSetRule; - - - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) -//@HasGetSetRuleFactory(RelatedGetSetObjRuleFactory.class) -@IsGetSetRule -@HasSetter(TypeRelatedSetObj.class) -public @interface TypeRelatedGetObj { - String value(); -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/TypeRelatedGetValue.java b/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/TypeRelatedGetValue.java deleted file mode 100644 index 1b0f147d..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/TypeRelatedGetValue.java +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.structural.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import org.simantics.objmap.graph.annotations.HasSetter; -import org.simantics.objmap.graph.annotations.meta.IsGetSetRule; -import org.simantics.objmap.graph.rules.adapters.IdentityAdapter; -import org.simantics.objmap.graph.rules.adapters.ValueAdapter; - - - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) -//@HasGetSetRuleFactory(RelatedGetSetValueRuleFactory.class) -@IsGetSetRule -@HasSetter(TypeRelatedSetValue.class) -public @interface TypeRelatedGetValue { - String value(); - Class adapter() default IdentityAdapter.class; -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/TypeRelatedSetObj.java b/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/TypeRelatedSetObj.java deleted file mode 100644 index 6045fb01..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/TypeRelatedSetObj.java +++ /dev/null @@ -1,24 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.structural.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) -public @interface TypeRelatedSetObj { - String value(); -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/TypeRelatedSetValue.java b/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/TypeRelatedSetValue.java deleted file mode 100644 index 61b061d6..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/TypeRelatedSetValue.java +++ /dev/null @@ -1,24 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.structural.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) -public @interface TypeRelatedSetValue { - String value(); -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/factories/DataTypeUtils.java b/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/factories/DataTypeUtils.java deleted file mode 100644 index 8218f367..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/factories/DataTypeUtils.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2013 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.structural.annotations.factories; - -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.layer0.Layer0; - -public class DataTypeUtils { - - public static Resource dataTypeOfClass(ReadGraph g, Class clazz) { - Layer0 b = Layer0.getInstance(g); - if(clazz.equals(Double.class) || clazz.equals(double.class)) - return b.Double; - else if(clazz.equals(String.class)) - return b.String; - else if(clazz.equals(Integer.class) || clazz.equals(int.class)) - return b.Integer; - else if(clazz.equals(Float.class) || clazz.equals(float.class)) - return b.Float; - else if(clazz.equals(Boolean.class) || clazz.equals(boolean.class)) - return b.Boolean; - else if(clazz.equals(Long.class) || clazz.equals(long.class)) - return b.Long; - else if(clazz.equals(Byte.class) || clazz.equals(byte.class)) - return b.Byte; - - else if(clazz.equals(double[].class)) - return b.DoubleArray; - else if(clazz.equals(int[].class)) - return b.IntegerArray; - else if(clazz.equals(byte[].class)) - return b.ByteArray; - else if(clazz.equals(float[].class)) - return b.FloatArray; - else if(clazz.equals(boolean[].class)) - return b.BooleanArray; - else if(clazz.equals(String[].class)) - return b.StringArray; - else if(clazz.equals(long[].class)) - return b.LongArray; - else { - System.out.println("Couldn't find a data type for " + clazz); - return null; - } - } - -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/factories/OptionalRelatedElementsRuleFactory.java b/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/factories/OptionalRelatedElementsRuleFactory.java deleted file mode 100644 index 734b3cd7..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/factories/OptionalRelatedElementsRuleFactory.java +++ /dev/null @@ -1,44 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2013 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.structural.annotations.factories; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Field; -import java.util.Collection; -import java.util.Collections; - -import org.simantics.db.ReadGraph; -import org.simantics.db.exception.ResourceNotFoundException; -import org.simantics.db.exception.ServiceException; -import org.simantics.db.exception.ValidationException; -import org.simantics.objmap.bidirectional.IBidirectionalMappingRule; -import org.simantics.objmap.graph.annotations.OptionalRelatedElements; -import org.simantics.objmap.graph.rules.MappedElementsRule; -import org.simantics.objmap.structural.rules.domain.RelatedObjectsAccessor; -import org.simantics.objmap.graph.rules.factory.IFieldRuleFactory; -import org.simantics.objmap.graph.rules.range.FieldAccessorWithDefault; -import org.simantics.objmap.structural.StructuralResource; - - -public class OptionalRelatedElementsRuleFactory implements IFieldRuleFactory { - - @Override - public IBidirectionalMappingRule create(ReadGraph g, Annotation _annotation, Field field) throws ResourceNotFoundException, ValidationException, ServiceException { - OptionalRelatedElements annotation = (OptionalRelatedElements)_annotation; - return new MappedElementsRule( - new RelatedObjectsAccessor(g.getResource(annotation.value()), - annotation.composition(),false), - new FieldAccessorWithDefault>(field, Collections.emptyList()) - ); - } - -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/factories/RelatedElementRuleFactory.java b/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/factories/RelatedElementRuleFactory.java deleted file mode 100644 index 3576bc5f..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/factories/RelatedElementRuleFactory.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2013 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.structural.annotations.factories; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Field; - -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.exception.ResourceNotFoundException; -import org.simantics.db.exception.ServiceException; -import org.simantics.db.exception.ValidationException; -import org.simantics.objmap.bidirectional.IBidirectionalMappingRule; -import org.simantics.objmap.graph.annotations.RelatedElement; -import org.simantics.objmap.graph.rules.MappedElementRule; -import org.simantics.objmap.graph.rules.domain.RelatedObjectAccessor; -import org.simantics.objmap.graph.rules.factory.IFieldRuleFactory; -import org.simantics.objmap.graph.rules.range.FieldAccessor; - - -public class RelatedElementRuleFactory implements IFieldRuleFactory { - - @Override - public IBidirectionalMappingRule create(ReadGraph g, Annotation _annotation, Field field) throws ResourceNotFoundException, ValidationException, ServiceException { - RelatedElement annotation = (RelatedElement)_annotation; - return new MappedElementRule( - new RelatedObjectAccessor(g.getResource(annotation.value())), - new FieldAccessor(field) - ); - } - -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/factories/RelatedElementsRuleFactory.java b/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/factories/RelatedElementsRuleFactory.java deleted file mode 100644 index a2d0a4c2..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/factories/RelatedElementsRuleFactory.java +++ /dev/null @@ -1,43 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2013 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.structural.annotations.factories; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Field; -import java.util.Collection; - -import org.simantics.db.ReadGraph; -import org.simantics.db.exception.ResourceNotFoundException; -import org.simantics.db.exception.ServiceException; -import org.simantics.db.exception.ValidationException; -import org.simantics.objmap.bidirectional.IBidirectionalMappingRule; -import org.simantics.objmap.graph.annotations.RelatedElements; -import org.simantics.objmap.graph.rules.MappedElementsRule; -import org.simantics.objmap.structural.rules.domain.RelatedObjectsAccessor; -import org.simantics.objmap.graph.rules.factory.IFieldRuleFactory; -import org.simantics.objmap.graph.rules.range.FieldAccessor; -import org.simantics.objmap.structural.StructuralResource; - - -public class RelatedElementsRuleFactory implements IFieldRuleFactory { - - @Override - public IBidirectionalMappingRule create(ReadGraph g, Annotation _annotation, Field field) throws ResourceNotFoundException, ValidationException, ServiceException { - RelatedElements annotation = (RelatedElements)_annotation; - return new MappedElementsRule( - new RelatedObjectsAccessor(g.getResource(annotation.value()), - annotation.composition(),false), - new FieldAccessor>(field) - ); - } - -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/factories/RelatedElementsRuleFactory2.java b/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/factories/RelatedElementsRuleFactory2.java deleted file mode 100644 index e100c7ab..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/factories/RelatedElementsRuleFactory2.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.structural.annotations.factories; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Method; - -import org.simantics.db.ReadGraph; -import org.simantics.db.exception.DatabaseException; -import org.simantics.objmap.bidirectional.IBidirectionalMappingRule; -import org.simantics.objmap.graph.annotations.RelatedElementsAdd; -import org.simantics.objmap.graph.annotations.RelatedElementsGet; -import org.simantics.objmap.graph.annotations.RelatedElementsRem; -import org.simantics.objmap.graph.rules.MappedElementsRule; -import org.simantics.objmap.graph.rules.factory.ICollectionRuleFactory; -import org.simantics.objmap.graph.rules.range.CollectionAccessor; -import org.simantics.objmap.structural.StructuralResource; -import org.simantics.objmap.structural.rules.domain.RelatedObjectsAccessor; - - -public class RelatedElementsRuleFactory2 implements ICollectionRuleFactory { - - @Override - public IBidirectionalMappingRule create(ReadGraph g, Annotation annotation, - Method getter, Method adder, Method remover) - throws DatabaseException { - RelatedElementsGet getterAnn = (RelatedElementsGet)annotation; - return new MappedElementsRule(new RelatedObjectsAccessor(g.getResource(getterAnn.value()),getterAnn.composition(),false,true,false), - new CollectionAccessor(getter, adder, remover)); - } - - @Override - public boolean isAdder(Annotation getterAnnotation, Annotation annotation) { - RelatedElementsGet getterAnn = (RelatedElementsGet)getterAnnotation; - RelatedElementsAdd adderAnn = (RelatedElementsAdd)annotation; - return getterAnn.value().equals(adderAnn.value()); - } - - @Override - public boolean isRemover(Annotation getterAnnotation, Annotation annotation) { - RelatedElementsGet getterAnn = (RelatedElementsGet)getterAnnotation; - RelatedElementsRem adderAnn = (RelatedElementsRem)annotation; - return getterAnn.value().equals(adderAnn.value()); - } - -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/factories/RelatedGetSetObjRuleFactory.java b/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/factories/RelatedGetSetObjRuleFactory.java deleted file mode 100644 index f1b3f354..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/factories/RelatedGetSetObjRuleFactory.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.structural.annotations.factories; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Method; - -import org.simantics.db.ReadGraph; -import org.simantics.db.exception.DatabaseException; -import org.simantics.objmap.bidirectional.IBidirectionalMappingRule; -import org.simantics.objmap.graph.annotations.RelatedGetObj; -import org.simantics.objmap.graph.annotations.RelatedSetObj; -import org.simantics.objmap.graph.rules.MappedElementRule; -import org.simantics.objmap.structural.rules.domain.RelatedObjectAccessor; -import org.simantics.objmap.graph.rules.factory.IGetSetRuleFactory; -import org.simantics.objmap.graph.rules.range.GetSetObjectAccessor; -import org.simantics.objmap.structural.StructuralResource; - - -/** - * Rule factory for mapped object using Getter/Setter-methods. - * - * @author Marko Luukkainen - * - */ -public class RelatedGetSetObjRuleFactory implements IGetSetRuleFactory { - - @Override - public IBidirectionalMappingRule create(ReadGraph g, Annotation annotation, - Method getter, Method setter) - throws DatabaseException { - RelatedGetObj getterAnn = (RelatedGetObj)annotation; - return new MappedElementRule(new RelatedObjectAccessor(g.getResource(getterAnn.value()),false,true,false), - new GetSetObjectAccessor(getter, setter)); - } - - @Override - public boolean isSetter(Annotation getterAnnotation, Annotation annotation) { - RelatedGetObj getterAnn = (RelatedGetObj)getterAnnotation; - RelatedSetObj setterAnn = (RelatedSetObj)annotation; - return getterAnn.value().equals(setterAnn.value()); - } - - - -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/factories/RelatedGetSetValueRuleFactory.java b/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/factories/RelatedGetSetValueRuleFactory.java deleted file mode 100644 index e1b8d2d3..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/factories/RelatedGetSetValueRuleFactory.java +++ /dev/null @@ -1,112 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.structural.annotations.factories; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Method; - -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.exception.DatabaseException; -import org.simantics.layer0.Layer0; -import org.simantics.objmap.bidirectional.IBidirectionalMappingRule; -import org.simantics.objmap.graph.annotations.RelatedGetValue; -import org.simantics.objmap.graph.annotations.RelatedSetValue; -import org.simantics.objmap.graph.rules.ValueRule; -import org.simantics.objmap.graph.rules.adapters.IdentityAdapter; -import org.simantics.objmap.graph.rules.adapters.ValueAdapter; -import org.simantics.objmap.structural.StructuralResource; -import org.simantics.objmap.structural.rules.domain.RelatedValueAccessor; -import org.simantics.objmap.graph.rules.factory.IGetSetRuleFactory; -import org.simantics.objmap.graph.rules.range.AdaptedRangeAccessor; -import org.simantics.objmap.graph.rules.range.GetSetValueAccessor; -import org.simantics.objmap.graph.rules.range.IRangeAccessor; - -/** - * Rule factory for mapped value using Getter/Setter-methods. - * - * @author Marko Luukkainen - * - */ -public class RelatedGetSetValueRuleFactory implements IGetSetRuleFactory { - - @Override - public IBidirectionalMappingRule create(ReadGraph g, Annotation annotation, - Method getter, Method setter) - throws DatabaseException { - RelatedGetValue getterAnn = (RelatedGetValue)annotation; - - Class adapterClass = getterAnn.adapter(); - IRangeAccessor rangeAccessor = new GetSetValueAccessor(getter, setter); - Resource valueType; - if (adapterClass == IdentityAdapter.class) { - valueType = dataTypeOfClass(g, getter.getReturnType()); - } else { - try{ - ValueAdapter adapter = adapterClass.newInstance(); - rangeAccessor = new AdaptedRangeAccessor(rangeAccessor, adapter); - valueType = adapter.rangeTypeToDomainType(g, getter.getReturnType()); - } catch (InstantiationException e) { - throw new RuntimeException(e); - } catch (IllegalAccessException e) { - throw new RuntimeException(e); - } - } - return new ValueRule(new RelatedValueAccessor(g.getResource(getterAnn.value()), valueType,false,true,false), - rangeAccessor); - } - - @Override - public boolean isSetter(Annotation getterAnnotation, Annotation annotation) { - RelatedGetValue getterAnn = (RelatedGetValue)getterAnnotation; - RelatedSetValue setterAnn = (RelatedSetValue)annotation; - return getterAnn.value().equals(setterAnn.value()); - } - - public static Resource dataTypeOfClass(ReadGraph g, Class clazz) { - Layer0 b = Layer0.getInstance(g); - if(clazz.equals(Double.class) || clazz.equals(double.class)) - return b.Double; - else if(clazz.equals(String.class)) - return b.String; - else if(clazz.equals(Integer.class) || clazz.equals(int.class)) - return b.Integer; - else if(clazz.equals(Float.class) || clazz.equals(float.class)) - return b.Float; - else if(clazz.equals(Boolean.class) || clazz.equals(boolean.class)) - return b.Boolean; - else if(clazz.equals(Long.class) || clazz.equals(long.class)) - return b.Long; - else if(clazz.equals(Byte.class) || clazz.equals(byte.class)) - return b.Byte; - - else if(clazz.equals(double[].class)) - return b.DoubleArray; - else if(clazz.equals(int[].class)) - return b.IntegerArray; - else if(clazz.equals(byte[].class)) - return b.ByteArray; - else if(clazz.equals(float[].class)) - return b.FloatArray; - else if(clazz.equals(boolean[].class)) - return b.BooleanArray; - else if(clazz.equals(String[].class)) - return b.StringArray; - else if(clazz.equals(long[].class)) - return b.LongArray; - else { - System.out.println("Couldn't find a data type for " + clazz); - return null; - } - } - -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/factories/RelatedOrderedSetElementsRuleFactory.java b/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/factories/RelatedOrderedSetElementsRuleFactory.java deleted file mode 100644 index b2e65648..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/factories/RelatedOrderedSetElementsRuleFactory.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2013 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.structural.annotations.factories; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Field; -import java.util.Collection; - -import org.simantics.db.ReadGraph; -import org.simantics.db.exception.ResourceNotFoundException; -import org.simantics.db.exception.ServiceException; -import org.simantics.db.exception.ValidationException; -import org.simantics.objmap.bidirectional.IBidirectionalMappingRule; -import org.simantics.objmap.graph.annotations.RelatedOrderedSetElements; -import org.simantics.objmap.graph.rules.MappedElementsRule; -import org.simantics.objmap.graph.rules.factory.IFieldRuleFactory; -import org.simantics.objmap.graph.rules.range.FieldAccessor; -import org.simantics.objmap.structural.StructuralResource; -import org.simantics.objmap.structural.rules.domain.RelatedOrderedSetElementsAccessor; - - -public class RelatedOrderedSetElementsRuleFactory implements IFieldRuleFactory { - - @Override - public IBidirectionalMappingRule create(ReadGraph g, Annotation _annotation, Field field) throws ResourceNotFoundException, ValidationException, ServiceException { - RelatedOrderedSetElements annotation = (RelatedOrderedSetElements)_annotation; - return new MappedElementsRule( - new RelatedOrderedSetElementsAccessor(annotation.composition(),false), - new FieldAccessor>(field) - ); - } - -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/factories/RelatedValueRuleFactory.java b/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/factories/RelatedValueRuleFactory.java deleted file mode 100644 index 0b4b34dd..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/factories/RelatedValueRuleFactory.java +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2013 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.structural.annotations.factories; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Field; - -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.exception.ResourceNotFoundException; -import org.simantics.db.exception.ServiceException; -import org.simantics.db.exception.ValidationException; - -import org.simantics.objmap.bidirectional.IBidirectionalMappingRule; -import org.simantics.objmap.graph.annotations.RelatedValue; -import org.simantics.objmap.graph.rules.ValueRule; -import org.simantics.objmap.graph.rules.adapters.IdentityAdapter; -import org.simantics.objmap.graph.rules.adapters.ValueAdapter; -import org.simantics.objmap.structural.rules.domain.RelatedValueAccessor; -import org.simantics.objmap.graph.rules.factory.IFieldRuleFactory; -import org.simantics.objmap.graph.rules.range.AdaptedRangeAccessor; -import org.simantics.objmap.graph.rules.range.FieldAccessor; -import org.simantics.objmap.graph.rules.range.IRangeAccessor; -import org.simantics.objmap.structural.StructuralResource; - - -public class RelatedValueRuleFactory implements IFieldRuleFactory { - - @Override - public IBidirectionalMappingRule create(ReadGraph g, Annotation _annotation, Field field) throws ResourceNotFoundException, - ValidationException, ServiceException { - RelatedValue annotation = (RelatedValue) _annotation; - Class adapterClass = annotation.adapter(); - IRangeAccessor rangeAccessor = new FieldAccessor(field); - Resource valueType; - if (adapterClass == IdentityAdapter.class) { - valueType = DataTypeUtils.dataTypeOfClass(g, field.getType()); - } else { - try { - ValueAdapter adapter = adapterClass.newInstance(); - rangeAccessor = new AdaptedRangeAccessor(rangeAccessor, adapter); - valueType = adapter.rangeTypeToDomainType(g, field.getType()); - } catch (InstantiationException e) { - throw new RuntimeException(e); - } catch (IllegalAccessException e) { - throw new RuntimeException(e); - } - } - return new ValueRule(new RelatedValueAccessor(g.getResource(annotation.value()), valueType,false,true,false), rangeAccessor); - } - -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/factories/StructuralRelatedElementsRuleFactory2.java b/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/factories/StructuralRelatedElementsRuleFactory2.java deleted file mode 100644 index b54c7350..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/factories/StructuralRelatedElementsRuleFactory2.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.structural.annotations.factories; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Method; - -import org.simantics.db.ReadGraph; -import org.simantics.db.exception.DatabaseException; -import org.simantics.objmap.bidirectional.IBidirectionalMappingRule; -import org.simantics.objmap.graph.rules.MappedElementsRule; -import org.simantics.objmap.graph.rules.factory.ICollectionRuleFactory; -import org.simantics.objmap.graph.rules.range.CollectionAccessor; -import org.simantics.objmap.structural.StructuralResource; -import org.simantics.objmap.structural.annotations.StructuralRelatedElementsAdd; -import org.simantics.objmap.structural.annotations.StructuralRelatedElementsGet; -import org.simantics.objmap.structural.annotations.StructuralRelatedElementsRem; -import org.simantics.objmap.structural.rules.domain.StructuralRelatedObjectsAccessor; - - -public class StructuralRelatedElementsRuleFactory2 implements ICollectionRuleFactory { - - @Override - public IBidirectionalMappingRule create(ReadGraph g, Annotation annotation, - Method getter, Method adder, Method remover) - throws DatabaseException { - StructuralRelatedElementsGet getterAnn = (StructuralRelatedElementsGet)annotation; - return new MappedElementsRule(new StructuralRelatedObjectsAccessor(g.getResource(getterAnn.value()),getterAnn.composition()), - new CollectionAccessor(getter, adder, remover)); - } - - @Override - public boolean isAdder(Annotation getterAnnotation, Annotation annotation) { - StructuralRelatedElementsGet getterAnn = (StructuralRelatedElementsGet)getterAnnotation; - StructuralRelatedElementsAdd adderAnn = (StructuralRelatedElementsAdd)annotation; - return getterAnn.value().equals(adderAnn.value()); - } - - @Override - public boolean isRemover(Annotation getterAnnotation, Annotation annotation) { - StructuralRelatedElementsGet getterAnn = (StructuralRelatedElementsGet)getterAnnotation; - StructuralRelatedElementsRem adderAnn = (StructuralRelatedElementsRem)annotation; - return getterAnn.value().equals(adderAnn.value()); - } - -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/factories/StructuralRelatedGetSetObjRuleFactory.java b/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/factories/StructuralRelatedGetSetObjRuleFactory.java deleted file mode 100644 index 22b8b08b..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/factories/StructuralRelatedGetSetObjRuleFactory.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.structural.annotations.factories; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Method; - -import org.simantics.db.ReadGraph; -import org.simantics.db.exception.DatabaseException; -import org.simantics.objmap.bidirectional.IBidirectionalMappingRule; -import org.simantics.objmap.graph.rules.MappedElementRule; -import org.simantics.objmap.graph.rules.factory.IGetSetRuleFactory; -import org.simantics.objmap.graph.rules.range.GetSetObjectAccessor; -import org.simantics.objmap.structural.StructuralResource; -import org.simantics.objmap.structural.annotations.StructuralRelatedGetObj; -import org.simantics.objmap.structural.annotations.StructuralRelatedSetObj; -import org.simantics.objmap.structural.rules.domain.StructuralRelatedObjectAccessor; - - -/** - * Rule factory for mapped object using Getter/Setter-methods. - * - * @author Marko Luukkainen - * - */ -public class StructuralRelatedGetSetObjRuleFactory implements IGetSetRuleFactory { - - @Override - public IBidirectionalMappingRule create(ReadGraph g, Annotation annotation, - Method getter, Method setter) - throws DatabaseException { - StructuralRelatedGetObj getterAnn = (StructuralRelatedGetObj)annotation; - return new MappedElementRule(new StructuralRelatedObjectAccessor(g.getResource(getterAnn.value()),false,true,false), - new GetSetObjectAccessor(getter, setter)); - } - - @Override - public boolean isSetter(Annotation getterAnnotation, Annotation annotation) { - StructuralRelatedGetObj getterAnn = (StructuralRelatedGetObj)getterAnnotation; - StructuralRelatedSetObj setterAnn = (StructuralRelatedSetObj)annotation; - return getterAnn.value().equals(setterAnn.value()); - } - - - -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/factories/TypeRelatedElementsRuleFactory2.java b/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/factories/TypeRelatedElementsRuleFactory2.java deleted file mode 100644 index 0bbc2b98..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/factories/TypeRelatedElementsRuleFactory2.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.structural.annotations.factories; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Method; - -import org.simantics.db.ReadGraph; -import org.simantics.db.exception.DatabaseException; -import org.simantics.objmap.bidirectional.IBidirectionalMappingRule; -import org.simantics.objmap.graph.rules.MappedElementsRule; -import org.simantics.objmap.graph.rules.factory.ICollectionRuleFactory; -import org.simantics.objmap.graph.rules.range.CollectionAccessor; -import org.simantics.objmap.structural.StructuralResource; -import org.simantics.objmap.structural.annotations.TypeRelatedElementsAdd; -import org.simantics.objmap.structural.annotations.TypeRelatedElementsGet; -import org.simantics.objmap.structural.annotations.TypeRelatedElementsRem; -import org.simantics.objmap.structural.rules.domain.RelatedObjectsAccessor; - - -public class TypeRelatedElementsRuleFactory2 implements ICollectionRuleFactory { - - @Override - public IBidirectionalMappingRule create(ReadGraph g, Annotation annotation, - Method getter, Method adder, Method remover) - throws DatabaseException { - TypeRelatedElementsGet getterAnn = (TypeRelatedElementsGet)annotation; - return new MappedElementsRule(new RelatedObjectsAccessor(g.getResource(getterAnn.value()),getterAnn.composition(),true,true,true), - new CollectionAccessor(getter, adder, remover)); - } - - @Override - public boolean isAdder(Annotation getterAnnotation, Annotation annotation) { - TypeRelatedElementsGet getterAnn = (TypeRelatedElementsGet)getterAnnotation; - TypeRelatedElementsAdd adderAnn = (TypeRelatedElementsAdd)annotation; - return getterAnn.value().equals(adderAnn.value()); - } - - @Override - public boolean isRemover(Annotation getterAnnotation, Annotation annotation) { - TypeRelatedElementsGet getterAnn = (TypeRelatedElementsGet)getterAnnotation; - TypeRelatedElementsRem adderAnn = (TypeRelatedElementsRem)annotation; - return getterAnn.value().equals(adderAnn.value()); - } - -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/factories/TypeRelatedGetSetObjRuleFactory.java b/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/factories/TypeRelatedGetSetObjRuleFactory.java deleted file mode 100644 index 57847184..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/factories/TypeRelatedGetSetObjRuleFactory.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.structural.annotations.factories; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Method; - -import org.simantics.db.ReadGraph; -import org.simantics.db.exception.DatabaseException; -import org.simantics.objmap.bidirectional.IBidirectionalMappingRule; -import org.simantics.objmap.graph.rules.MappedElementRule; -import org.simantics.objmap.graph.rules.factory.IGetSetRuleFactory; -import org.simantics.objmap.graph.rules.range.GetSetObjectAccessor; -import org.simantics.objmap.structural.StructuralResource; -import org.simantics.objmap.structural.annotations.TypeRelatedGetObj; -import org.simantics.objmap.structural.annotations.TypeRelatedSetObj; -import org.simantics.objmap.structural.rules.domain.RelatedObjectAccessor; - - -/** - * Rule factory for mapped object using Getter/Setter-methods. - * - * @author Marko Luukkainen - * - */ -public class TypeRelatedGetSetObjRuleFactory implements IGetSetRuleFactory { - - @Override - public IBidirectionalMappingRule create(ReadGraph g, Annotation annotation, - Method getter, Method setter) - throws DatabaseException { - TypeRelatedGetObj getterAnn = (TypeRelatedGetObj)annotation; - return new MappedElementRule(new RelatedObjectAccessor(g.getResource(getterAnn.value()),true,true,true), - new GetSetObjectAccessor(getter, setter)); - } - - @Override - public boolean isSetter(Annotation getterAnnotation, Annotation annotation) { - TypeRelatedGetObj getterAnn = (TypeRelatedGetObj)getterAnnotation; - TypeRelatedSetObj setterAnn = (TypeRelatedSetObj)annotation; - return getterAnn.value().equals(setterAnn.value()); - } - - - -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/factories/TypeRelatedGetSetValueRuleFactory.java b/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/factories/TypeRelatedGetSetValueRuleFactory.java deleted file mode 100644 index 60fb6ac7..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/factories/TypeRelatedGetSetValueRuleFactory.java +++ /dev/null @@ -1,112 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.structural.annotations.factories; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Method; - -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.exception.DatabaseException; -import org.simantics.layer0.Layer0; -import org.simantics.objmap.bidirectional.IBidirectionalMappingRule; -import org.simantics.objmap.graph.rules.ValueRule; -import org.simantics.objmap.graph.rules.adapters.IdentityAdapter; -import org.simantics.objmap.graph.rules.adapters.ValueAdapter; -import org.simantics.objmap.graph.rules.factory.IGetSetRuleFactory; -import org.simantics.objmap.graph.rules.range.AdaptedRangeAccessor; -import org.simantics.objmap.graph.rules.range.GetSetValueAccessor; -import org.simantics.objmap.graph.rules.range.IRangeAccessor; -import org.simantics.objmap.structural.StructuralResource; -import org.simantics.objmap.structural.annotations.TypeRelatedGetValue; -import org.simantics.objmap.structural.annotations.TypeRelatedSetValue; -import org.simantics.objmap.structural.rules.domain.RelatedValueAccessor; - -/** - * Rule factory for mapped value using Getter/Setter-methods. - * - * @author Marko Luukkainen - * - */ -public class TypeRelatedGetSetValueRuleFactory implements IGetSetRuleFactory { - - @Override - public IBidirectionalMappingRule create(ReadGraph g, Annotation annotation, - Method getter, Method setter) - throws DatabaseException { - TypeRelatedGetValue getterAnn = (TypeRelatedGetValue)annotation; - - Class adapterClass = getterAnn.adapter(); - IRangeAccessor rangeAccessor = new GetSetValueAccessor(getter, setter); - Resource valueType; - if (adapterClass == IdentityAdapter.class) { - valueType = dataTypeOfClass(g, getter.getReturnType()); - } else { - try{ - ValueAdapter adapter = adapterClass.newInstance(); - rangeAccessor = new AdaptedRangeAccessor(rangeAccessor, adapter); - valueType = adapter.rangeTypeToDomainType(g, getter.getReturnType()); - } catch (InstantiationException e) { - throw new RuntimeException(e); - } catch (IllegalAccessException e) { - throw new RuntimeException(e); - } - } - return new ValueRule(new RelatedValueAccessor(g.getResource(getterAnn.value()), valueType,true,true,true), - rangeAccessor); - } - - @Override - public boolean isSetter(Annotation getterAnnotation, Annotation annotation) { - TypeRelatedGetValue getterAnn = (TypeRelatedGetValue)getterAnnotation; - TypeRelatedSetValue setterAnn = (TypeRelatedSetValue)annotation; - return getterAnn.value().equals(setterAnn.value()); - } - - public static Resource dataTypeOfClass(ReadGraph g, Class clazz) { - Layer0 b = Layer0.getInstance(g); - if(clazz.equals(Double.class) || clazz.equals(double.class)) - return b.Double; - else if(clazz.equals(String.class)) - return b.String; - else if(clazz.equals(Integer.class) || clazz.equals(int.class)) - return b.Integer; - else if(clazz.equals(Float.class) || clazz.equals(float.class)) - return b.Float; - else if(clazz.equals(Boolean.class) || clazz.equals(boolean.class)) - return b.Boolean; - else if(clazz.equals(Long.class) || clazz.equals(long.class)) - return b.Long; - else if(clazz.equals(Byte.class) || clazz.equals(byte.class)) - return b.Byte; - - else if(clazz.equals(double[].class)) - return b.DoubleArray; - else if(clazz.equals(int[].class)) - return b.IntegerArray; - else if(clazz.equals(byte[].class)) - return b.ByteArray; - else if(clazz.equals(float[].class)) - return b.FloatArray; - else if(clazz.equals(boolean[].class)) - return b.BooleanArray; - else if(clazz.equals(String[].class)) - return b.StringArray; - else if(clazz.equals(long[].class)) - return b.LongArray; - else { - System.out.println("Couldn't find a data type for " + clazz); - return null; - } - } - -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/factories/UpdateMethodFactory.java b/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/factories/UpdateMethodFactory.java deleted file mode 100644 index b7f1fc23..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/factories/UpdateMethodFactory.java +++ /dev/null @@ -1,70 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2013 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.structural.annotations.factories; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Method; - -import org.apache.log4j.Logger; -import org.simantics.db.ReadGraph; -import org.simantics.db.WriteGraph; -import org.simantics.db.exception.DatabaseException; -import org.simantics.objmap.backward.IBackwardMapping; -import org.simantics.objmap.bidirectional.IBidirectionalMappingRule; -import org.simantics.objmap.exceptions.MappingException; -import org.simantics.objmap.forward.IForwardMapping; -import org.simantics.objmap.graph.rules.factory.IMethodRuleFactory; - -public class UpdateMethodFactory implements IMethodRuleFactory { - - static Logger LOGGER = Logger.getLogger("org.simantics.objmap"); - - @Override - public IBidirectionalMappingRule create(ReadGraph g, - Annotation annotation, - final Method method) - throws DatabaseException { - method.setAccessible(true); - return new IBidirectionalMappingRule() { - - @Override - public boolean updateRange(ReadGraph g, IForwardMapping map, - Domain domainElement, Range rangeElement) - throws MappingException { - LOGGER.info(" UpdateMethodFactory.updateRange"); - try { - return (Boolean)method.invoke(rangeElement, g, domainElement); - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - return false; - } - - @Override - public boolean updateDomain(WriteGraph g, IBackwardMapping map, - Domain domainElement, Range rangeElement) - throws MappingException { - return false; - } - - public void createDomain(WriteGraph g, IBackwardMapping map, Domain domainElement, Range rangeElement) throws MappingException { - updateDomain(g, map, domainElement, rangeElement); - }; - - public void createRange(ReadGraph g, IForwardMapping map, Domain domainElement, Range rangeElement) throws MappingException { - updateRange(g, map, domainElement, rangeElement); - }; - }; - } - -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/structural/rules/domain/RelatedObjectAccessor.java b/org.simantics.objmap2/src/org/simantics/objmap/structural/rules/domain/RelatedObjectAccessor.java deleted file mode 100644 index 6fa4af73..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/structural/rules/domain/RelatedObjectAccessor.java +++ /dev/null @@ -1,111 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2013 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.structural.rules.domain; - -import org.apache.log4j.Logger; -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.WriteGraph; -import org.simantics.db.exception.DatabaseException; -import org.simantics.objmap.exceptions.MappingException; -import org.simantics.objmap.graph.rules.domain.IDomainAccessor; -import org.simantics.objmap.structural.StructuralResource; - - -public class RelatedObjectAccessor implements IDomainAccessor { - - static Logger LOGGER = Logger.getLogger("org.simantics.objmap"); - - Resource relation; - boolean useTypeResource; - - private boolean preventStructuralChanges = true; - private boolean preventStructuralRootChanges = true; - - public RelatedObjectAccessor(Resource relation, boolean useTypeResource) { - this.relation = relation; - this.useTypeResource = useTypeResource; - } - - public RelatedObjectAccessor(Resource relation, boolean useTypeResource, boolean preventStructuralChanges, boolean preventStructuralRootChanges) { - this.relation = relation; - this.useTypeResource = useTypeResource; - this.preventStructuralChanges = preventStructuralChanges; - this.preventStructuralRootChanges = preventStructuralRootChanges; - } - - private boolean preventChange(StructuralResource element) { - return preventStructuralChanges && element.isStructural() && (!element.isStructuralRoot()||preventStructuralRootChanges); - } - - @Override - public StructuralResource get(ReadGraph g, StructuralResource element) throws MappingException { - try { - LOGGER.info(" RelatedObjectAccessor.get"); - Resource res = getServiceResource(g, element); - if (res == null) - return null; - Resource r = g.getPossibleObject(res, relation); - if (r == null) - return null; - if (StructuralUtils.isStructuralInstance(g, r)) { - return new StructuralResource(g, r, element.getContext(),r); - } else { - return new StructuralResource(g, r, element.getContext()); - } - } catch (DatabaseException e) { - throw new MappingException(e); - } - } - - @Override - public boolean set(WriteGraph g, StructuralResource selement, StructuralResource value) - throws MappingException { - try { - LOGGER.info(" RelatedObjectAccessor.set"); - Resource element = getServiceResource(g, selement); - if (element == null) - return false; - Resource resource = g.getPossibleObject(element, relation); - if(resource == null) { - if(value == null) - return false; - if (preventChange(selement)) - return false; - g.claim(element, relation, value.getResource()); - return true; - } - else if(resource.equals(value)) - return false; - else { - if (preventChange(selement)) - return false; - g.deny(element, relation); - if(value != null) - g.claim(element, relation, value.getResource()); - return true; - } - } catch (DatabaseException e) { - throw new MappingException(e); - } - - } - - - - private Resource getServiceResource(ReadGraph g, StructuralResource element) { - if(!useTypeResource) - return element.getResource(); - return element.getTypeResource(); - } - -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/structural/rules/domain/RelatedObjectsAccessor.java b/org.simantics.objmap2/src/org/simantics/objmap/structural/rules/domain/RelatedObjectsAccessor.java deleted file mode 100644 index c56ffb6d..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/structural/rules/domain/RelatedObjectsAccessor.java +++ /dev/null @@ -1,113 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2013 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.structural.rules.domain; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -import org.apache.log4j.Logger; -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.WriteGraph; -import org.simantics.db.exception.DatabaseException; -import org.simantics.objmap.exceptions.MappingException; -import org.simantics.objmap.graph.rules.domain.IDomainAccessor; -import org.simantics.objmap.graph.rules.domain.MappingUtils; -import org.simantics.objmap.structural.StructuralResource; - - -public class RelatedObjectsAccessor implements IDomainAccessor> { - - static Logger LOGGER = Logger.getLogger("org.simantics.objmap"); - - Resource relation; - boolean deleteExtraObjects; - boolean useTypeResource; - - private boolean preventStructuralChanges = true; - private boolean preventStructuralRootChanges = true; - - public RelatedObjectsAccessor(Resource relation, boolean deleteExtraObjects, boolean useTypeResource) { - super(); - this.relation = relation; - this.deleteExtraObjects = deleteExtraObjects; - this.useTypeResource = useTypeResource; - } - - public RelatedObjectsAccessor(Resource relation, boolean deleteExtraObjects, boolean useTypeResource, boolean preventStructuralChanges, boolean preventStructuralRootChanges) { - super(); - this.relation = relation; - this.deleteExtraObjects = deleteExtraObjects; - this.useTypeResource = useTypeResource; - this.preventStructuralChanges = preventStructuralChanges; - this.preventStructuralRootChanges = preventStructuralRootChanges; - } - - @Override - public Collection get(ReadGraph g, StructuralResource element) throws MappingException { - try { - LOGGER.info(" RelatedObjectsAccessor.get"); - - - Resource res = getServiceResource(g, element); - if (res == null) - return Collections.emptyList(); - Collection coll = g.getObjects(res, relation); - List result = new ArrayList(coll.size()); - for (Resource r : coll) { - if (StructuralUtils.isStructuralInstance(g, r)) { - result.add(new StructuralResource(g, r, element.getContext(),r)); - } else { - result.add(new StructuralResource(g, r, element.getContext())); - } - } - return result; - } catch (DatabaseException e) { - throw new MappingException(e); - } - } - - private boolean preventChange(StructuralResource element) { - return preventStructuralChanges && element.isStructural() && (!element.isStructuralRoot()||preventStructuralRootChanges); - } - - @Override - public boolean set(WriteGraph g, StructuralResource element, Collection value) - throws MappingException { - try { - LOGGER.info(" RelatedObjectsAccessor.set"); - Resource res = getServiceResource(g, element); - if (res == null) - return false; - if (preventChange(element)) - return false; - Resource[] arr = new Resource[value.size()]; - int i = 0; - for (StructuralResource sr : value) { - arr[i++] = sr.getResource(); - } - return MappingUtils.synchronizeStatements(g, res, relation, - arr, deleteExtraObjects); - } catch (DatabaseException e) { - throw new MappingException(e); - } - - } - - private Resource getServiceResource(ReadGraph g, StructuralResource element) { - if (!useTypeResource) - return element.getResource(); - return element.getTypeResource(); - } -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/structural/rules/domain/RelatedOrderedSetElementsAccessor.java b/org.simantics.objmap2/src/org/simantics/objmap/structural/rules/domain/RelatedOrderedSetElementsAccessor.java deleted file mode 100644 index c9b63e4c..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/structural/rules/domain/RelatedOrderedSetElementsAccessor.java +++ /dev/null @@ -1,86 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2013 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.structural.rules.domain; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -import org.apache.log4j.Logger; -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.WriteGraph; -import org.simantics.db.common.utils.OrderedSetUtils; -import org.simantics.db.exception.DatabaseException; -import org.simantics.objmap.exceptions.MappingException; -import org.simantics.objmap.graph.rules.domain.IDomainAccessor; -import org.simantics.objmap.structural.StructuralResource; - -public class RelatedOrderedSetElementsAccessor implements IDomainAccessor> { - - static Logger LOGGER = Logger.getLogger("org.simantics.objmap"); - - boolean deleteExtraObjects; - boolean useTypeResource; - - public RelatedOrderedSetElementsAccessor(boolean deleteExtraObjects, boolean useTypeResource) { - super(); - this.deleteExtraObjects = deleteExtraObjects; - this.useTypeResource = useTypeResource; - } - - @Override - public Collection get(ReadGraph g, StructuralResource element) throws MappingException { - try { - LOGGER.info(" RelatedOrderedSetElementsAccessor.get"); - Resource res = getServiceResource(g, element); - if (res == null) - return Collections.emptyList(); - List list = OrderedSetUtils.toList(g, res); - List result = new ArrayList(list.size()); - for (Resource r : list) { - result.add(new StructuralResource(g,r,element.getContext())); - } - return result; - } catch (DatabaseException e) { - throw new MappingException(e); - } - } - - @Override - public boolean set(WriteGraph g, StructuralResource element, Collection value) - throws MappingException { - try { - LOGGER.info(" RelatedOrderedSetElementsAccessor.set"); - Resource res = getServiceResource(g, element); - if (res == null) - return false; - List list = new ArrayList(value.size()); - for (StructuralResource r : value) { - list.add(r.getResource()); - } - return OrderedSetUtils.set(g, res, list); - // FIXME Implement deleteExtraObjects - } catch (DatabaseException e) { - throw new MappingException(e); - } - - } - - private Resource getServiceResource(ReadGraph g, StructuralResource element) { - if (!useTypeResource) - return element.getResource(); - return element.getTypeResource(); - } - -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/structural/rules/domain/RelatedValueAccessor.java b/org.simantics.objmap2/src/org/simantics/objmap/structural/rules/domain/RelatedValueAccessor.java deleted file mode 100644 index 84516fcd..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/structural/rules/domain/RelatedValueAccessor.java +++ /dev/null @@ -1,150 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2013 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.structural.rules.domain; - -import java.util.Arrays; - -import org.apache.log4j.Logger; -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.Statement; -import org.simantics.db.WriteGraph; -import org.simantics.db.exception.DatabaseException; -import org.simantics.layer0.Layer0; -import org.simantics.objmap.exceptions.MappingException; -import org.simantics.objmap.graph.rules.domain.IDomainAccessor; -import org.simantics.objmap.structural.StructuralResource; - - -public class RelatedValueAccessor implements IDomainAccessor { - - static Logger LOGGER = Logger.getLogger("org.simantics.objmap"); - - Resource relation; - Resource valueType; - boolean useTypeResource; - - private boolean preventStructuralChanges = true; - private boolean preventStructuralRootChanges = true; - - public RelatedValueAccessor(Resource relation, Resource valueType, boolean useTypeResource) { - this.relation = relation; - this.valueType = valueType; - this.useTypeResource = useTypeResource; - } - - public RelatedValueAccessor(Resource relation, Resource valueType, boolean useTypeResource, boolean preventStructuralChanges, boolean preventStructuralRootChanges) { - this.relation = relation; - this.valueType = valueType; - this.useTypeResource = useTypeResource; - this.preventStructuralChanges = preventStructuralChanges; - this.preventStructuralRootChanges = preventStructuralRootChanges; - } - - private boolean preventChange(StructuralResource element) { - return preventStructuralChanges && element.isStructural() && (!element.isStructuralRoot()||preventStructuralRootChanges); - } - - @Override - public Object get(ReadGraph g, StructuralResource element) throws MappingException { - try { - LOGGER.info(" RelatedValueAccessor.get"); - Resource res = getServiceResource(g, element); - if (res == null) - return null; - Resource valueResource = g.getPossibleObject(res, relation); - if(valueResource == null) - return null; - return g.getValue(valueResource); - } catch (DatabaseException e) { - throw new MappingException(e); - } - } - - @Override - public boolean set(WriteGraph g, StructuralResource relement, Object value) - throws MappingException { - try { - LOGGER.info(" RelatedValueAccessor.set"); - - Resource element = getServiceResource(g, relement); - if (element == null) - return false; - Statement valueStatement = g.getPossibleStatement(element, relation); - if(valueStatement == null) { - if(value == null) - return false; - if (preventChange(relement)) - return false; - Resource valueResource = g.newResource(); - g.claim(valueResource, Layer0.getInstance(g).InstanceOf, null, - valueType); - g.claim(element, relation, valueResource); - g.claimValue(valueResource, value); - return true; - } - else { - if(value == null) { - if (preventChange(relement)) - return false; - if (!valueStatement.isAsserted(element)) { - g.deny(valueStatement.getObject()); - return true; - } else { - return false; - } - - } - Object currentValue = g.getValue(valueStatement.getObject()); - if(equals(currentValue,value)) - return false; - if (preventChange(relement)) - return false; - if (!valueStatement.isAsserted(element)) - g.claimValue(valueStatement.getObject(), value); - else { - Resource valueResource = g.newResource(); - g.claim(valueResource, Layer0.getInstance(g).InstanceOf, null, - valueType); - g.claim(element, relation, valueResource); - g.claimValue(valueResource, value); - } - return true; - } - } catch (DatabaseException e) { - throw new MappingException(e); - } - - } - - private Resource getServiceResource(ReadGraph g, StructuralResource element) { - if (!useTypeResource) - return element.getResource(); - return element.getTypeResource(); - } - - private boolean equals(Object o1, Object o2) { - if (o1 instanceof boolean[]) - Arrays.equals((boolean[])o1,(boolean[])o2); - if (o1 instanceof int[]) - Arrays.equals((int[])o1,(int[])o2); - if (o1 instanceof float[]) - Arrays.equals((float[])o1,(float[])o2); - if (o1 instanceof double[]) - Arrays.equals((double[])o1,(double[])o2); - if (o1 instanceof byte[]) - Arrays.equals((byte[])o1,(byte[])o2); - return o1.equals(o2); - - } - -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/structural/rules/domain/StructuralRelatedObjectAccessor.java b/org.simantics.objmap2/src/org/simantics/objmap/structural/rules/domain/StructuralRelatedObjectAccessor.java deleted file mode 100644 index 66e6ea90..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/structural/rules/domain/StructuralRelatedObjectAccessor.java +++ /dev/null @@ -1,131 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2013 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.structural.rules.domain; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.log4j.Logger; -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.WriteGraph; -import org.simantics.db.exception.DatabaseException; -import org.simantics.objmap.exceptions.MappingException; -import org.simantics.objmap.graph.rules.domain.IDomainAccessor; -import org.simantics.objmap.structural.StructuralResource; - - -public class StructuralRelatedObjectAccessor implements IDomainAccessor { - - static Logger LOGGER = Logger.getLogger("org.simantics.objmap"); - - Resource relation; - boolean useTypeResource; - - private boolean preventStructuralChanges = true; - private boolean preventStructuralRootChanges = true; - - public StructuralRelatedObjectAccessor(Resource relation, boolean useTypeResource) { - this.relation = relation; - this.useTypeResource = useTypeResource; - } - - public StructuralRelatedObjectAccessor(Resource relation, boolean useTypeResource, boolean preventStructuralChanges, boolean preventStructuralRootChanges) { - this.relation = relation; - this.useTypeResource = useTypeResource; - this.preventStructuralChanges = preventStructuralChanges; - this.preventStructuralRootChanges = preventStructuralRootChanges; - } - - private boolean preventChange(StructuralResource element) { - return preventStructuralChanges && element.isStructural() && (!element.isStructuralRoot()||preventStructuralRootChanges); - } - - @Override - public StructuralResource get(ReadGraph g, StructuralResource element) throws MappingException { - try { - - LOGGER.info(" RelatedObjectAccessor.get"); - - if (!element.isStructural()) - return null; - Resource instance = StructuralUtils.getContainingInstance(element); - - Resource publicRelation = StructuralUtils.getPublishedRelation(g, element, relation); - - if (publicRelation == null) - return null; - Resource r = g.getPossibleObject(instance, publicRelation); - if (r == null) - return null; - List context = new ArrayList(); - for (int i = 0; i < element.getContext().size()-1; i++) - context.add(element.getContext().get(i)); - if (StructuralUtils.isStructuralInstance(g, r)) { - return new StructuralResource(g, r, context,r); - } else { - return new StructuralResource(g, r, context); - } - } catch (DatabaseException e) { - throw new MappingException(e); - } - } - - @Override - public boolean set(WriteGraph g, StructuralResource element, StructuralResource value) - throws MappingException { - try { - LOGGER.info(" RelatedObjectAccessor.set"); - Resource instance = StructuralUtils.getContainingInstance(element); - Resource publicRelation = null; - if (instance == null) - return false; - publicRelation = StructuralUtils.getPublishedRelation(g, element, relation); - if (value == null) { - if (publicRelation == null) - return false; - if (preventChange(element)) - return false; - g.deny(instance, publicRelation); - return true; - } else { - if (publicRelation == null) { - if (preventChange(element)) - return false; - publicRelation = StructuralUtils.getOrCreatePublishedRelation(g, element, relation); - g.claim(instance, publicRelation, value.getResource()); - return true; - } else { - Resource r = g.getPossibleObject(instance, publicRelation); - if (r == null) { - if (preventChange(element)) - return false; - g.claim(instance, publicRelation, value.getResource()); - return true; - } else { - if (r.equals(value.getResource())) - return false; - if (preventChange(element)) - return false; - g.deny(instance, publicRelation); - g.claim(instance, publicRelation, value.getResource()); - return true; - } - } - } - } catch (DatabaseException e) { - throw new MappingException(e); - } - - } - -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/structural/rules/domain/StructuralRelatedObjectsAccessor.java b/org.simantics.objmap2/src/org/simantics/objmap/structural/rules/domain/StructuralRelatedObjectsAccessor.java deleted file mode 100644 index c2bc6f9e..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/structural/rules/domain/StructuralRelatedObjectsAccessor.java +++ /dev/null @@ -1,116 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2013 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.structural.rules.domain; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -import org.apache.log4j.Logger; -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.WriteGraph; -import org.simantics.db.exception.DatabaseException; -import org.simantics.objmap.exceptions.MappingException; -import org.simantics.objmap.graph.rules.domain.IDomainAccessor; -import org.simantics.objmap.graph.rules.domain.MappingUtils; -import org.simantics.objmap.structural.StructuralResource; - - -public class StructuralRelatedObjectsAccessor implements IDomainAccessor> { - - static Logger LOGGER = Logger.getLogger("org.simantics.objmap"); - - Resource relation; - boolean deleteExtraObjects; - - public StructuralRelatedObjectsAccessor(Resource relation, boolean deleteExtraObjects) { - super(); - this.relation = relation; - this.deleteExtraObjects = deleteExtraObjects; - } - - @Override - public Collection get(ReadGraph g, StructuralResource element) throws MappingException { - try { - LOGGER.info(" RelatedObjectsAccessor.get"); - - if (!element.isStructural()) - return Collections.emptyList(); - - // Structural instance - Resource instance = StructuralUtils.getContainingInstance(element); - - Resource publicRelation = StructuralUtils.getPublishedRelation(g, element, relation); - - if (publicRelation == null) - return Collections.emptyList(); - - Collection coll = g.getObjects(instance, publicRelation); - List result = new ArrayList(coll.size()); - List context = new ArrayList(); - for (int i = 0; i < element.getContext().size()-1; i++) - context.add(element.getContext().get(i)); - for (Resource r : coll) { - if (StructuralUtils.isStructuralInstance(g, r)) { - result.add(new StructuralResource(g, r, context,r)); - } else { - result.add(new StructuralResource(g, r, context)); - } - } - return result; - } catch (DatabaseException e) { - throw new MappingException(e); - } - } - - @Override - public boolean set(WriteGraph g, StructuralResource element, Collection value) - throws MappingException { - try { - LOGGER.info(" RelatedObjectsAccessor.set"); - - if (!element.isStructural()) - return false; - - Resource instance = StructuralUtils.getContainingInstance(element); - Resource publicRelation = null; - if (value.size() == 0) { - publicRelation = StructuralUtils.getPublishedRelation(g, element, relation); - if (publicRelation == null) - return false; - else { - return MappingUtils.synchronizeStatements(g, instance, publicRelation, new Resource[0], deleteExtraObjects); - } - } else { - publicRelation = StructuralUtils.getOrCreatePublishedRelation(g, element, relation); - if (publicRelation == null) - throw new MappingException("Structural Resource " + element + " cannot contain structural elements, the Resource is not published."); - Resource[] arr = new Resource[value.size()]; - int i = 0; - for (StructuralResource sr : value) { - arr[i++] = sr.getResource(); - } - return MappingUtils.synchronizeStatements(g, instance, publicRelation, arr, deleteExtraObjects); - } - - - - } catch (DatabaseException e) { - throw new MappingException(e); - } - - } - - -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/structural/rules/domain/StructuralUtils.java b/org.simantics.objmap2/src/org/simantics/objmap/structural/rules/domain/StructuralUtils.java deleted file mode 100644 index 0f0d1e77..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/structural/rules/domain/StructuralUtils.java +++ /dev/null @@ -1,116 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.structural.rules.domain; - -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.WriteGraph; -import org.simantics.db.exception.DatabaseException; -import org.simantics.db.exception.NoSingleResultException; -import org.simantics.layer0.Layer0; -import org.simantics.objmap.structural.StructuralResource; -import org.simantics.structural.stubs.StructuralResource2; - -public class StructuralUtils { - - - public static boolean isStructuralInstance(ReadGraph g, Resource r) throws DatabaseException { - StructuralResource2 sr = StructuralResource2.getInstance(g); - if (g.isInstanceOf(r, sr.Component)) { - Resource type = g.getSingleType(r); - return g.isInstanceOf(type, sr.Component); - } - return false; - - } - - public static Resource getContainingInstance(StructuralResource element) { - if (!element.isStructural()) - return null; - Resource instance = element.getContext().get(element.getContext().size()-1); - return instance; - } - - public static Resource getPublishedRelation(ReadGraph g, StructuralResource element, Resource relation) throws DatabaseException{ - Resource instance = getContainingInstance(element); - if (instance == null) - return null; - - Layer0 l0 = Layer0.getInstance(g); - StructuralResource2 sr = StructuralResource2.getInstance(g); - - Resource type = null; - try { - type = g.getSingleType(instance); - } catch (NoSingleResultException e) { - - } - if (type == null) - return null; - - boolean elementPublished = false; - Resource publicRelation = null; - for (Resource r : g.getObjects(type, l0.DomainOf)) { - if (r.equals(element.getResource())) - elementPublished = true; - if (g.isInstanceOf(r, relation)) { - if (element.getResource().equals(g.getPossibleObject(r, sr.IsBoundBy))) - publicRelation = r; - } - } - if (!elementPublished) - return null; - return publicRelation; - } - - public static Resource getOrCreatePublishedRelation(WriteGraph g, StructuralResource element, Resource relation) throws DatabaseException{ - Resource instance = getContainingInstance(element); - if (instance == null) - return null; - - Layer0 l0 = Layer0.getInstance(g); - StructuralResource2 sr = StructuralResource2.getInstance(g); - - Resource type = g.getSingleType(instance); - - boolean elementPublished = false; - Resource publicRelation = null; - for (Resource r : g.getObjects(type, l0.DomainOf)) { - if (r.equals(element.getResource())) - elementPublished = true; - if (g.isInstanceOf(r, relation)) { - if (element.getResource().equals(g.getPossibleObject(r, sr.IsBoundBy))) - publicRelation = r; - } - } - if (!elementPublished) - return null; - if (publicRelation != null) - return publicRelation; - - publicRelation = g.newResource(); - // TODO: type ConsistsOf publicRelation, publicRelation ConsistsOf publicInverse ? - g.claim(publicRelation, l0.SubrelationOf, l0.IsRelatedTo); - g.claim(publicRelation, l0.InstanceOf, relation); - g.claim(publicRelation, sr.IsBoundBy, element.getResource()); - g.claim(type, l0.DomainOf, publicRelation); - g.claimLiteral(publicRelation, l0.HasName, g.getRelatedValue(element.getResource(), l0.HasName) +"_" + g.getRelatedValue(relation, l0.HasName)); - Resource inverse = g.getPossibleInverse(relation); - if (inverse != null) { - Resource publicInverse = g.newResource(); - g.claim(publicInverse, l0.SubrelationOf, inverse); - g.claim(publicRelation, l0.InverseOf, publicInverse); - } - return publicRelation; - - } -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/structural/schema/AdaptedLinkType.java b/org.simantics.objmap2/src/org/simantics/objmap/structural/schema/AdaptedLinkType.java deleted file mode 100644 index adb60d10..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/structural/schema/AdaptedLinkType.java +++ /dev/null @@ -1,90 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.structural.schema; - -//import org.apache.log4j.Logger; -import org.eclipse.core.runtime.IAdaptable; -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.WriteGraph; -import org.simantics.db.exception.DatabaseException; -import org.simantics.objmap.backward.IBackwardMapping; -import org.simantics.objmap.exceptions.MappingException; -import org.simantics.objmap.forward.IForwardMapping; -import org.simantics.objmap.graph.schema.ILinkType; -import org.simantics.objmap.structural.IStructuralObject; -import org.simantics.objmap.structural.StructuralResource; - -/** - * A link type that is associated with adaptable resource (ReadGraph.getAdapter(Resource,Class)). - * The adapted object must implement IAdaptable interface for returning the original Resource. - * - * @author Marko Luukkainen - * - */ -public class AdaptedLinkType implements ILinkType { - - - //static Logger LOGGER = Logger.getLogger("org.simantics.objmap"); - - Resource domainType; - Class rangeType; - - - public AdaptedLinkType(Resource domainType, Class rangeType) { - this.domainType = domainType; - this.rangeType = rangeType; - } - - @Override - public StructuralResource createDomainElement(WriteGraph g, IStructuralObject rangeElement) - throws MappingException { - try { - IAdaptable adaptable = (IAdaptable)rangeElement; - Resource res = (Resource)adaptable.getAdapter(Resource.class); - if (res == null) - throw new NullPointerException(); - return new StructuralResource(g,res); - } catch (Exception e) { - throw new MappingException("Adapted object must implement IAdaptable interface to return the source Resource.", e); - } - - } - - - @Override - public IStructuralObject createRangeElement(ReadGraph g, StructuralResource domainElement) - throws MappingException { - try { - // FIXME : this will not work, we cannot assume that adapted objects would implement IStructuralObject interface. - return (IStructuralObject)g.adapt(domainElement.getResource(), rangeType); - } catch (DatabaseException e) { - throw new MappingException(e); - } - } - - public void createDomain(WriteGraph graph, IBackwardMapping mapping, StructuralResource domainElement, IStructuralObject rangeElement) throws MappingException { - - }; - - public void createRange(ReadGraph graph, org.simantics.objmap.forward.IForwardMapping mapping, StructuralResource domainElement, IStructuralObject rangeElement) throws MappingException { - - }; - - public boolean updateDomain(WriteGraph g, IBackwardMapping map, StructuralResource domainElement, IStructuralObject rangeElement) throws MappingException { - return false; - } - - public boolean updateRange(ReadGraph g, IForwardMapping map, StructuralResource domainElement, IStructuralObject rangeElement) throws MappingException { - return false; - } -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/structural/schema/DefaultSchema.java b/org.simantics.objmap2/src/org/simantics/objmap/structural/schema/DefaultSchema.java deleted file mode 100644 index 0c8b6ca8..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/structural/schema/DefaultSchema.java +++ /dev/null @@ -1,123 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2013 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.structural.schema; - - - -import java.util.Stack; - -import gnu.trove.map.hash.THashMap; - -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.common.utils.NameUtils; -import org.simantics.db.exception.DatabaseException; -import org.simantics.objmap.exceptions.MappingException; -import org.simantics.objmap.graph.schema.ILinkType; -import org.simantics.objmap.graph.schema.IMappingSchema; -import org.simantics.objmap.structural.IStructuralObject; -import org.simantics.objmap.structural.StructuralResource; - - -/** - * - */ -public class DefaultSchema implements IMappingSchema { - - THashMap> domainLinkTypes = - new THashMap>(); - THashMap, ILinkType> rangeLinkTypes = - new THashMap, ILinkType>(); - - public void addLinkType(SimpleLinkType linkType) { - domainLinkTypes.put(linkType.domainType, linkType); - rangeLinkTypes.put(linkType.rangeType, linkType); - } - - public void addLinkType(AdaptedLinkType linkType) { - domainLinkTypes.put(linkType.domainType, linkType); - rangeLinkTypes.put(linkType.rangeType, linkType); - } - - @Override - public ILinkType linkTypeOfDomainElement(ReadGraph g, StructuralResource element) throws MappingException { - try { - - for(Resource type : g.getTypes(element.getResource())) { - - ILinkType linkType = domainLinkTypes.get(type); - if(linkType != null) return linkType; - - } - - throw new MappingException("Didn't find a link type for " + - NameUtils.getSafeName(g, element.getResource()) + "."); - - } catch (DatabaseException e) { - throw new MappingException(e); - } - } - - @Override - public ILinkType linkTypeOfRangeElement(IStructuralObject element) throws MappingException { - ILinkType type = rangeLinkTypes.get(element.getClass()); - if(type == null) { - Stack> clazzes = new Stack>(); - for (Class clazz : element.getClass().getInterfaces()) { - clazzes.add(clazz); - } - clazzes.add(element.getClass().getSuperclass()); - - while (!clazzes.isEmpty()) { - Class clazz = clazzes.pop(); - - type = rangeLinkTypes.get(clazz); - if (type != null) - return type; - for (Class c : clazz.getInterfaces()) - clazzes.add(c); - - } - throw new MappingException("Didn't find a link type for " + element + "."); - } - return type; - } - - - public ILinkType linkTypeOfDomainType(ReadGraph g, Resource type) { - return domainLinkTypes.get(type); - } - - public ILinkType linkTypeOfRangeType(Class clazz) { - ILinkType type = rangeLinkTypes.get(clazz); - if(type == null) { - Stack> clazzes = new Stack>(); - for (Class c : clazz.getInterfaces()) { - clazzes.add(c); - } - clazzes.add(clazz.getSuperclass()); - - while (!clazzes.isEmpty()) { - Class c = clazzes.pop(); - - type = rangeLinkTypes.get(c); - if (type != null) - return type; - for (Class c2 : c.getInterfaces()) - clazzes.add(c2); - - } - - } - return null; - } -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/structural/schema/MappingSchemas.java b/org.simantics.objmap2/src/org/simantics/objmap/structural/schema/MappingSchemas.java deleted file mode 100644 index 3f9169ec..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/structural/schema/MappingSchemas.java +++ /dev/null @@ -1,266 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.structural.schema; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.Collection; - -import org.simantics.db.ReadGraph; -import org.simantics.db.exception.DatabaseException; -import org.simantics.objmap.bidirectional.IBidirectionalMappingRule; -import org.simantics.objmap.graph.annotations.GraphType; -import org.simantics.objmap.graph.annotations.HasCollectionAdder; -import org.simantics.objmap.graph.annotations.HasCollectionRemover; -import org.simantics.objmap.graph.annotations.HasSetter; -import org.simantics.objmap.graph.annotations.OptionalRelatedElements; -import org.simantics.objmap.graph.annotations.OrderedSetType; -import org.simantics.objmap.graph.annotations.RelatedElements; -import org.simantics.objmap.graph.annotations.RelatedElementsGet; -import org.simantics.objmap.graph.annotations.RelatedGetObj; -import org.simantics.objmap.graph.annotations.RelatedGetValue; -import org.simantics.objmap.graph.annotations.RelatedOrderedSetElements; -import org.simantics.objmap.graph.annotations.RelatedValue; -import org.simantics.objmap.graph.annotations.UpdateMethod; -import org.simantics.objmap.graph.annotations.meta.IsClassRule; -import org.simantics.objmap.graph.annotations.meta.IsCollectionRule; -import org.simantics.objmap.graph.annotations.meta.IsFieldRule; -import org.simantics.objmap.graph.annotations.meta.IsGetSetRule; -import org.simantics.objmap.graph.annotations.meta.IsMethodRule; -import org.simantics.objmap.graph.rules.factory.IClassRuleFactory; -import org.simantics.objmap.graph.rules.factory.ICollectionRuleFactory; -import org.simantics.objmap.graph.rules.factory.IFieldRuleFactory; -import org.simantics.objmap.graph.rules.factory.IGetSetRuleFactory; -import org.simantics.objmap.graph.rules.factory.IMethodRuleFactory; -import org.simantics.objmap.structural.IStructuralObject; -import org.simantics.objmap.structural.StructuralResource; -import org.simantics.objmap.structural.annotations.StructuralRelatedElementsGet; -import org.simantics.objmap.structural.annotations.StructuralRelatedGetObj; -import org.simantics.objmap.structural.annotations.TypeRelatedElementsGet; -import org.simantics.objmap.structural.annotations.TypeRelatedGetObj; -import org.simantics.objmap.structural.annotations.TypeRelatedGetValue; -import org.simantics.objmap.structural.annotations.factories.OptionalRelatedElementsRuleFactory; -import org.simantics.objmap.structural.annotations.factories.RelatedElementsRuleFactory; -import org.simantics.objmap.structural.annotations.factories.RelatedElementsRuleFactory2; -import org.simantics.objmap.structural.annotations.factories.RelatedGetSetObjRuleFactory; -import org.simantics.objmap.structural.annotations.factories.RelatedGetSetValueRuleFactory; -import org.simantics.objmap.structural.annotations.factories.RelatedOrderedSetElementsRuleFactory; -import org.simantics.objmap.structural.annotations.factories.RelatedValueRuleFactory; -import org.simantics.objmap.structural.annotations.factories.StructuralRelatedElementsRuleFactory2; -import org.simantics.objmap.structural.annotations.factories.StructuralRelatedGetSetObjRuleFactory; -import org.simantics.objmap.structural.annotations.factories.TypeRelatedElementsRuleFactory2; -import org.simantics.objmap.structural.annotations.factories.TypeRelatedGetSetObjRuleFactory; -import org.simantics.objmap.structural.annotations.factories.TypeRelatedGetSetValueRuleFactory; -import org.simantics.objmap.structural.annotations.factories.UpdateMethodFactory; - - -public class MappingSchemas { - /** - * Creates a new SimpleLinkType based on the annotations in the given class. - * @throws IllegalAccessException - * @throws InstantiationException - * @see GraphType - * @see RelatedValue - */ - public static SimpleLinkType fromAnnotations(ReadGraph g, Class clazz) throws DatabaseException, InstantiationException, IllegalAccessException { - GraphType graphType = clazz.getAnnotation(GraphType.class); - - if (graphType != null) { - ArrayList> rules = new ArrayList>(); - collectRulesFromAnnotations(g, clazz, rules); - - return new SimpleLinkType(g.getResource(graphType.value()), clazz, rules); - } - OrderedSetType orderedSetType = clazz.getAnnotation(OrderedSetType.class); - if (orderedSetType != null) { - ArrayList> rules = new ArrayList>(); - collectRulesFromAnnotations(g, clazz, rules); - - return new OrderedSetSimpleLinkType(g.getResource(orderedSetType.value()), clazz, rules); - } - throw new IllegalArgumentException("Class " + clazz.toString() + " does not contain annotations."); - } - - public static void collectRulesFromAnnotations(ReadGraph g, Class clazz, Collection> rules) throws DatabaseException, InstantiationException, IllegalAccessException { - Class superclass = clazz.getSuperclass(); - if(superclass != null) - collectRulesFromAnnotations(g, superclass, rules); - - for(Annotation annotation : clazz.getAnnotations()) { - - IsClassRule tag = annotation.annotationType().getAnnotation(IsClassRule.class); - if(tag!= null) { - rules.add(createClassRule(g, annotation, clazz).create(g, annotation, clazz)); - } - } - - for(Field f : clazz.getDeclaredFields()) { - f.setAccessible(true); - - for(Annotation annotation : f.getAnnotations()) { - - IsFieldRule tag = annotation.annotationType().getAnnotation(IsFieldRule.class); - if(tag != null) { - rules.add(createFieldRule(g, annotation, f).create(g, annotation, f)); - } - } - } - - for(Method m : clazz.getDeclaredMethods()) { - m.setAccessible(true); - - for(Annotation annotation : m.getAnnotations()) { - IsMethodRule tag = - annotation.annotationType().getAnnotation(IsMethodRule.class); - if(tag != null) { - rules.add(createMethodRule(g, annotation, m).create(g, annotation, m)); - } - } - } - - for (Method m : clazz.getDeclaredMethods()) { - m.setAccessible(true); - for (Annotation annotation : m.getAnnotations()) { - Class annotationType = annotation.annotationType(); - - IsGetSetRule tag = - annotationType.getAnnotation(IsGetSetRule.class); - if (tag != null) { - - HasSetter setterAnnType = annotationType.getAnnotation(HasSetter.class); - - Class setterAnn = setterAnnType.value(); - - Method getter = m; - - IGetSetRuleFactory ruleFactory = createGetSetRuleFactory(g, annotation, getter); - - - Method setter = null; - - for (Method m2 : clazz.getDeclaredMethods()) { - Annotation set = m2.getAnnotation(setterAnn); - if (set != null && ruleFactory.isSetter(annotation, set)) - setter = m2; - } - - rules.add(ruleFactory.create(g, annotation, getter, setter)); - } - - } - } - - for (Method m : clazz.getDeclaredMethods()) { - m.setAccessible(true); - for (Annotation annotation : m.getAnnotations()) { - Class annotationType = annotation.annotationType(); - - IsCollectionRule tag = - annotationType.getAnnotation(IsCollectionRule.class); - if (tag != null) { - - HasCollectionAdder adderAnnType = annotationType.getAnnotation(HasCollectionAdder.class); - HasCollectionRemover removerAnnType = annotationType.getAnnotation(HasCollectionRemover.class); - - Class adderAnn = adderAnnType.value(); - Class removerAnn = removerAnnType.value(); - - Method getter = m; - - ICollectionRuleFactory ruleFactory = createCollectionRuleFactory(g, annotation, getter); - - - Method adder = null; - Method remover = null; - - for (Method m2 : clazz.getDeclaredMethods()) { - Annotation add = m2.getAnnotation(adderAnn); - Annotation rem = m2.getAnnotation(removerAnn); - if (add != null && ruleFactory.isAdder(annotation, add)) - adder = m2; - if (rem != null && ruleFactory.isRemover(annotation, rem)) - remover = m2; - } - - - - rules.add(ruleFactory.create(g, annotation, getter,adder,remover)); - } - - } - } - } - - public static IClassRuleFactory createClassRule(ReadGraph g, Annotation annotation, Class clazz) { - return null; - } - - public static IFieldRuleFactory createFieldRule(ReadGraph g, Annotation annotation, Field field) { - if (annotation.annotationType().equals(RelatedElements.class)) - return new RelatedElementsRuleFactory(); - if (annotation.annotationType().equals(RelatedValue.class)) - return new RelatedValueRuleFactory(); - if (annotation.annotationType().equals(OptionalRelatedElements.class)) - return new OptionalRelatedElementsRuleFactory(); - if (annotation.annotationType().equals(RelatedOrderedSetElements.class)) - return new RelatedOrderedSetElementsRuleFactory(); - return null; - } - - public static IMethodRuleFactory createMethodRule(ReadGraph g, Annotation annotation, Method m) { - if (annotation.annotationType().equals(UpdateMethod.class)) - return new UpdateMethodFactory(); - return null; - } - - public static IGetSetRuleFactory createGetSetRuleFactory(ReadGraph g, Annotation annotation, Method getter) { - if (annotation.annotationType().equals(RelatedGetValue.class)) - return new RelatedGetSetValueRuleFactory(); - if (annotation.annotationType().equals(RelatedGetObj.class)) - return new RelatedGetSetObjRuleFactory(); - if (annotation.annotationType().equals(TypeRelatedGetValue.class)) - return new TypeRelatedGetSetValueRuleFactory(); - if (annotation.annotationType().equals(TypeRelatedGetObj.class)) - return new TypeRelatedGetSetObjRuleFactory(); - if (annotation.annotationType().equals(StructuralRelatedGetObj.class)) - return new StructuralRelatedGetSetObjRuleFactory(); - return null; - } - - public static ICollectionRuleFactory createCollectionRuleFactory(ReadGraph g, Annotation annotation, Method getter) { - if (annotation.annotationType().equals(RelatedElementsGet.class)) - return new RelatedElementsRuleFactory2(); - if (annotation.annotationType().equals(TypeRelatedElementsGet.class)) - return new TypeRelatedElementsRuleFactory2(); - if (annotation.annotationType().equals(StructuralRelatedElementsGet.class)) - return new StructuralRelatedElementsRuleFactory2(); - return null; - } - - - /** - * Creates a new SimpleLinkType based on the annotations in the given class. - * @throws IllegalAccessException - * @throws InstantiationException - * @see GraphType - * @see RelatedValue - */ - public static AdaptedLinkType fromAdaptable(ReadGraph g, String type, Class clazz) throws DatabaseException, InstantiationException, IllegalAccessException { - - - return new AdaptedLinkType(g.getResource(type), clazz); - } - - -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/structural/schema/OrderedSetSimpleLinkType.java b/org.simantics.objmap2/src/org/simantics/objmap/structural/schema/OrderedSetSimpleLinkType.java deleted file mode 100644 index 6fd6a016..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/structural/schema/OrderedSetSimpleLinkType.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.simantics.objmap.structural.schema; - -import java.util.ArrayList; - -import org.simantics.db.Resource; -import org.simantics.db.WriteGraph; -import org.simantics.db.common.utils.OrderedSetUtils; -import org.simantics.db.exception.DatabaseException; -import org.simantics.objmap.bidirectional.IBidirectionalMappingRule; -import org.simantics.objmap.structural.IStructuralObject; -import org.simantics.objmap.structural.StructuralResource; - -public class OrderedSetSimpleLinkType extends SimpleLinkType { - - public OrderedSetSimpleLinkType(Resource domainType, Class rangeType, ArrayList> rules) { - super(domainType, rangeType, rules); - } - - public OrderedSetSimpleLinkType(Resource domainType, Class rangeType) { - super(domainType, rangeType); - } - - @Override - protected Resource newResource(WriteGraph g, Resource type) throws DatabaseException { - return OrderedSetUtils.create(g, type); - } - -} diff --git a/org.simantics.objmap2/src/org/simantics/objmap/structural/schema/SimpleLinkType.java b/org.simantics.objmap2/src/org/simantics/objmap/structural/schema/SimpleLinkType.java deleted file mode 100644 index 7ad6b6d0..00000000 --- a/org.simantics.objmap2/src/org/simantics/objmap/structural/schema/SimpleLinkType.java +++ /dev/null @@ -1,190 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2013 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.structural.schema; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import org.apache.log4j.Logger; -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.WriteGraph; -import org.simantics.db.common.utils.NameUtils; -import org.simantics.db.exception.DatabaseException; -import org.simantics.layer0.Layer0; -import org.simantics.objmap.backward.IBackwardMapping; -import org.simantics.objmap.bidirectional.IBidirectionalMappingRule; -import org.simantics.objmap.exceptions.MappingException; -import org.simantics.objmap.forward.IForwardMapping; -import org.simantics.objmap.graph.schema.ILinkType; -import org.simantics.objmap.structural.IStructuralObject; -import org.simantics.objmap.structural.StructuralResource; - - - -public class SimpleLinkType implements ILinkType { - - static Logger LOGGER = Logger.getLogger("org.simantics.objmap"); - - public Resource domainType; - public Class rangeType; - ArrayList> rules; - - public SimpleLinkType(Resource domainType, Class rangeType, - ArrayList> rules) { - this.domainType = domainType; - this.rangeType = rangeType; - this.rules = rules; - } - - public SimpleLinkType(Resource domainType, Class rangeType) { - this(domainType, rangeType, new ArrayList>()); - } - - /** - * Adds a new rule to this link type that is enforced - * during updates. - */ - public void addRule(IBidirectionalMappingRule rule) { - rules.add(rule); - } - - @Override - public StructuralResource createDomainElement(WriteGraph g, IStructuralObject rangeElement) - throws MappingException { - try { - if(LOGGER.isInfoEnabled()) - LOGGER.info("SimpleLinkType.createDomainElement " + - rangeElement.toString() - ); - if (rangeElement.getContext().size() == 0) { - // there is no context, this not a structural resource / object. - Resource result = newResource(g, domainType); - return new StructuralResource(g,result); - } else { - if (rangeElement.getContext().size() == 1 && rangeElement.getContext().get(0).equals(rangeElement)) { - // Structural object's context is itself, we are instantiating a new structural model. - Resource type = rangeElement.getType(); - Resource result = newResource(g, type); - return new StructuralResource(g,result,result); - } else { - // Structural object's context is not itself, which means that the object is inside of a structural model. - // At the moment we do not support modifying instantiated structural models. - throw new MappingException("Cannot create a new StucturalObject " + rangeElement + " " + rangeElement.getClass()); - } - } - } catch(DatabaseException e) { - throw new MappingException(e); - } - } - - protected Resource newResource(WriteGraph g, Resource type) throws DatabaseException { - Resource result = g.newResource(); - g.claim(result, Layer0.getInstance(g).InstanceOf, null, type); - return result; - } - @Override - public IStructuralObject createRangeElement(ReadGraph g, StructuralResource domainElement) - throws MappingException { - try { - if(LOGGER.isInfoEnabled()) - try { - LOGGER.info("SimpleLinkType.createRangeElement " + NameUtils.getSafeName(g, domainElement.getResource())); - } catch(DatabaseException e) { - throw new MappingException(e); - } - IStructuralObject result = (IStructuralObject)rangeType.newInstance(); - if (domainElement.getContext().size() == 1) { - if (domainElement.getContext().get(0).equals(domainElement.getResource())) - result.setContext(Collections.singletonList(result)); - else { - //result.setContext(result); - } - } - return result; - } catch (InstantiationException e) { - throw new MappingException(e); - } catch (IllegalAccessException e) { - throw new MappingException(e); - } - } - - @SuppressWarnings("unchecked") - public void createDomain(WriteGraph graph, IBackwardMapping mapping, StructuralResource domainElement, IStructuralObject rangeElement) throws MappingException { - if (domainElement.isStructuralRoot()) - // FIXME: this is nasty, but when a structural model is instantiated by creating new IStructuralObject, its related objects must be read from the graph first, or otherwise the objects would be deleted from the graph. - // as a side effect, if the new IStructuralObject has any properties set, those properties are set to null (because the graph does not contain those values). - // - updateRange(graph, (IForwardMapping)mapping, domainElement, rangeElement); - updateDomain(graph, mapping, domainElement, rangeElement); - }; - - - @Override - public void createRange(ReadGraph graph, IForwardMapping mapping, StructuralResource domainElement, IStructuralObject rangeElement) throws MappingException { - if (rangeElement.getContext().size() == 0 && domainElement.getContext().size() > 0) { - List ctx = new ArrayList(domainElement.getContext().size()); - try { - List context = new ArrayList(); - for (int i = 0; i map, StructuralResource domainElement, IStructuralObject rangeElement) throws MappingException { - if(LOGGER.isInfoEnabled()) - try { - LOGGER.info("SimpleLinkType.updateDomain " + - NameUtils.getSafeName(g, domainElement.getResource()) + " " + - rangeElement.toString() - ); - } catch(DatabaseException e) { - throw new MappingException(e); - } - - boolean updated = false; - for(IBidirectionalMappingRule rule : rules) - updated |= rule.updateDomain(g, map, domainElement, rangeElement); - return updated; - } - - public boolean updateRange(ReadGraph g, IForwardMapping map, StructuralResource domainElement, IStructuralObject rangeElement) throws MappingException { - - if(LOGGER.isInfoEnabled()) - try { - LOGGER.info("SimpleLinkType.updateRange " + - NameUtils.getSafeName(g, domainElement.getResource()) + " " + - rangeElement.toString() - ); - } catch(DatabaseException e) { - throw new MappingException(e); - } - - boolean updated = false; - for(IBidirectionalMappingRule rule : rules) - updated |= rule.updateRange(g, map, domainElement, rangeElement); - return updated; - } -} diff --git a/pom.xml b/pom.xml index 7ed7b5b1..f1693bae 100644 --- a/pom.xml +++ b/pom.xml @@ -169,7 +169,6 @@ org.simantics.g3d.csg.ontology org.simantics.g3d.ontology org.simantics.g3d.vtk - org.simantics.objmap2 org.simantics.opencascade org.simantics.opencascade.vtk -- 2.45.2