de.interactive_instruments.ShapeChange.Model.Generic
Class GenericModel

java.lang.Object
  extended by de.interactive_instruments.ShapeChange.Model.ModelImpl
      extended by de.interactive_instruments.ShapeChange.Model.Generic.GenericModel
All Implemented Interfaces:
Model

public class GenericModel
extends ModelImpl

Author:
echterhoff

Nested Class Summary
static class GenericModel.PropertyCopyDuplicatBehaviorIndicator
          Identifies different behaviors for situations in which a property is intended to be copied to a class but another property with the same name already exists in that class.
static class GenericModel.PropertyCopyPositionIndicator
           
 
Field Summary
protected  Set<String> appSchemaPackageIds
           
protected  String characterEncoding
           
protected  Map<String,GenericPackageInfo> genAppSchema
          Key: application schema package name Value: the application schema package
protected  Map<String,GenericAssociationInfo> genAssociationInfosById
           
protected  Map<String,GenericClassInfo> genClassInfosById
           
protected  Map<String,GenericClassInfo> genClassInfosByName
           
protected  Map<String,GenericPackageInfo> genPackageInfosById
           
protected  Map<String,GenericPropertyInfo> genPropertiesById
           
protected  Model model
           
protected  Options options
           
protected  ShapeChangeResult result
           
 
Fields inherited from class de.interactive_instruments.ShapeChange.Model.ModelImpl
allowedTags, gmlTags, jsonTags, postprocessed, shapeChangeTags
 
Constructor Summary
GenericModel(Model model)
           
 
Method Summary
 void add(GenericPropertyInfo newProperty, ClassInfo classToAddProperty)
          Adds the property to the model map and also the given class.
 void add(GenericPropertyInfo newProperty, ClassInfo classToAddProperty, GenericModel.PropertyCopyDuplicatBehaviorIndicator behavior)
          Adds the property to the model map and also the given class.
 void addClass(GenericClassInfo genCi)
           
 String characterEncoding()
           
 ClassInfo classById(String id)
           
 ClassInfo classByName(String name)
           
 HashSet<ClassInfo> classes(PackageInfo pi)
          Return all ClassInfo objects contained in the given package and in sub- packages, which do not belong to an app schema different to the one of the given package.
 void copyClassContent(GenericClassInfo fromClass, GenericClassInfo toClass, GenericModel.PropertyCopyPositionIndicator copyPositionIndicator, GenericModel.PropertyCopyDuplicatBehaviorIndicator duplicateHandling)
          Copies the content of fromClass to toClass, including properties, associations (also self associations), but NOT constraints (because they are automatically retrieved and potentially overridden by each class while the input model is loaded).
 GenericAssociationInfo createCopy(AssociationInfo ai, String copyId)
          Creates a copy of the given association.
 GenericPropertyInfo createCopy(PropertyInfo pi, String copyId)
          Creates a copy of the given property.
 void dissolveAssociation(GenericAssociationInfo genAI)
          Basically turns the properties representing the two ends of an association into attributes of the classes they are in (unless the association end is not navigable).
 Set<GenericPackageInfo> getAppSchemaPackages()
           
 Map<String,GenericAssociationInfo> getGenAssociations()
           
 Map<String,GenericClassInfo> getGenClasses()
           
 Map<String,GenericPackageInfo> getGenPackages()
           
 Map<String,GenericPropertyInfo> getGenProperties()
           
 void initialise(ShapeChangeResult r, Options o, String repositoryFileName)
           
 boolean isInAppSchema(ClassInfo ci)
           
 boolean isInAppSchema(PackageInfo pi)
           
 Options options()
           
 PackageInfo packageById(String id)
           
 HashSet<PackageInfo> packages()
           
 void postprocessAfterLoadingAndValidate()
          Execute postprocessing and validation checks before the conversion
 void remove(Collection<GenericClassInfo> cisToRemove)
          Removes the given classes from the model.
 void remove(GenericClassInfo ciToRemove)
          Removes the given class from the model.
 void remove(GenericPropertyInfo genPi, boolean tryKeepAssociation)
          Removes the property from the model.
 void remove(Set<PackageInfo> packagesToRemove)
          Removes all of the packages in the set from the model, including all classes contained in these packages.
 void removeByClassCategory(int classCategory)
           
 void removeByClassId(String id)
           
 ShapeChangeResult result()
           
 HashSet<PackageInfo> schemas(String name)
          Collect and return all PackageInfo objects tagged as being a schema.
 void shutdown()
           
 String toString(String indent)
           
 int type()
           
 void updateClassName(GenericClassInfo genCi, String newName)
          Replaces the current name of the class with the given name, applying the update in the model as well (superclasses, subtypes, model, and property type info).
 
Methods inherited from class de.interactive_instruments.ShapeChange.Model.ModelImpl
initialise, normalizeTaggedValue, selectedSchemas
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

options

protected Options options

result

protected ShapeChangeResult result

characterEncoding

protected String characterEncoding

model

protected Model model

appSchemaPackageIds

protected Set<String> appSchemaPackageIds

genPropertiesById

protected Map<String,GenericPropertyInfo> genPropertiesById

genAssociationInfosById

protected Map<String,GenericAssociationInfo> genAssociationInfosById

genClassInfosById

protected Map<String,GenericClassInfo> genClassInfosById

genClassInfosByName

protected Map<String,GenericClassInfo> genClassInfosByName

genPackageInfosById

protected Map<String,GenericPackageInfo> genPackageInfosById

genAppSchema

protected Map<String,GenericPackageInfo> genAppSchema
Key: application schema package name Value: the application schema package

Constructor Detail

GenericModel

public GenericModel(Model model)
Method Detail

addClass

public void addClass(GenericClassInfo genCi)

isInAppSchema

public boolean isInAppSchema(PackageInfo pi)

isInAppSchema

public boolean isInAppSchema(ClassInfo ci)

options

public Options options()
See Also:
Model.options()

result

public ShapeChangeResult result()
See Also:
Model.result()

initialise

public void initialise(ShapeChangeResult r,
                       Options o,
                       String repositoryFileName)
                throws ShapeChangeAbortException
Throws:
ShapeChangeAbortException
See Also:
de.interactive_instruments.ShapeChange.Model.Model#initialise(de. interactive_instruments.ShapeChange.ShapeChangeResult, de.interactive_instruments.ShapeChange.Options, java.lang.String)

type

public int type()

schemas

public HashSet<PackageInfo> schemas(String name)
Collect and return all PackageInfo objects tagged as being a schema. If a name is given, only the package with the specified name will be considered.

See Also:
de.interactive_instruments.ShapeChange.Model.Model#schemas(java.lang. String)

classes

public HashSet<ClassInfo> classes(PackageInfo pi)
Return all ClassInfo objects contained in the given package and in sub- packages, which do not belong to an app schema different to the one of the given package.

See Also:
de.interactive_instruments.ShapeChange.Model.Model#classes(de. interactive_instruments.ShapeChange.Model.PackageInfo)

postprocessAfterLoadingAndValidate

public void postprocessAfterLoadingAndValidate()
Description copied from class: ModelImpl
Execute postprocessing and validation checks before the conversion

Specified by:
postprocessAfterLoadingAndValidate in interface Model
Overrides:
postprocessAfterLoadingAndValidate in class ModelImpl
See Also:
postprocessAfterLoadingAndValidate()

packageById

public PackageInfo packageById(String id)
See Also:
de.interactive_instruments.ShapeChange.Model.Model#packageById(java.lang .String)

classById

public ClassInfo classById(String id)
See Also:
de.interactive_instruments.ShapeChange.Model.Model#classById(java.lang .String)

classByName

public ClassInfo classByName(String name)
See Also:
de.interactive_instruments.ShapeChange.Model.Model#classByName(java.lang .String)

shutdown

public void shutdown()
See Also:
Model.shutdown()

characterEncoding

public String characterEncoding()
See Also:
Model.characterEncoding()

toString

public String toString(String indent)

add

public void add(GenericPropertyInfo newProperty,
                ClassInfo classToAddProperty)
Adds the property to the model map and also the given class. WARNING: if the new property has the same name as an already existing one it will simply be added, not ignored or overwriting the existing one. Use the method add(GenericPropertyInfo, ClassInfo, PropertyCopyDuplicatBehaviorIndicator) to control this behavior.

Parameters:
newProperty -
classToAddProperty -

add

public void add(GenericPropertyInfo newProperty,
                ClassInfo classToAddProperty,
                GenericModel.PropertyCopyDuplicatBehaviorIndicator behavior)
Adds the property to the model map and also the given class. The behavior how to handle the case that the new property has the same name as an already existing one is controlled by the behavior parameter.

Parameters:
newProperty -
classToAddProperty -
behavior -

remove

public void remove(GenericClassInfo ciToRemove)
Removes the given class from the model. The model is updated to reflect this change, which involves: - Removing all properties of the class. - Removing all properties whose type is the class. - Removing all associations with at least one of these properties. - Removing all association classes of these associations. - Removing the class and all identified association classes from their packages. - Removing the relationships to super- and subtypes of the class.

Parameters:
ciToRemove -

remove

public void remove(Collection<GenericClassInfo> cisToRemove)
Removes the given classes from the model. Internally calls the remove(GenericClassInfo) method.

Parameters:
cisToRemove -

getGenAssociations

public Map<String,GenericAssociationInfo> getGenAssociations()
Returns:
map of all generic associations within the application schema (key: association id, value: association)

getGenProperties

public Map<String,GenericPropertyInfo> getGenProperties()
Returns:
map of all generic properties within the application schema (key: property id, value: property)

getGenPackages

public Map<String,GenericPackageInfo> getGenPackages()
Returns:
map of all generic packages within the application schema (key: package id, value: package)

getGenClasses

public Map<String,GenericClassInfo> getGenClasses()
Returns:
map of all generic classes within the application schema (key: class id, value: class)

remove

public void remove(GenericPropertyInfo genPi,
                   boolean tryKeepAssociation)
Removes the property from the model. If the property is not part of an association, it is removed from both the model and its class. If the property is part of an association, then the behavior depends upon the boolean parameter tryKeepAssociation: if it is false, then the association is removed with both its properties and any association class. Otherwise the given property is set to be non-navigable (also removing that property from its inClass). If both association ends then are no longer navigable, the association is removed with both its properties and any association class.

Parameters:
genPi - the property that potentially is removed from the model and its class (depends on the tryKeepAssociation parameter and whether the property is navigable or not)
tryKeepAssociation - true if the algorithm should only delete the property if the association it potentially belongs to is no longer navigable (in both directions) after the property has been set to be non-navigable, false if any association the property belongs to shall be removed outright.

removeByClassCategory

public void removeByClassCategory(int classCategory)

getAppSchemaPackages

public Set<GenericPackageInfo> getAppSchemaPackages()

copyClassContent

public void copyClassContent(GenericClassInfo fromClass,
                             GenericClassInfo toClass,
                             GenericModel.PropertyCopyPositionIndicator copyPositionIndicator,
                             GenericModel.PropertyCopyDuplicatBehaviorIndicator duplicateHandling)
Copies the content of fromClass to toClass, including properties, associations (also self associations), but NOT constraints (because they are automatically retrieved and potentially overridden by each class while the input model is loaded). Does not copy operations or dependencies.

Parameters:
fromClass -
toClass -
copyPositionIndicator -
duplicateHandling -

createCopy

public GenericAssociationInfo createCopy(AssociationInfo ai,
                                         String copyId)
Creates a copy of the given association. Only updates the id and copies tagged values, but does not update the objects (e.g. association ends or class; they need to be set separately).

Parameters:
ai -
copyId -
Returns:

createCopy

public GenericPropertyInfo createCopy(PropertyInfo pi,
                                      String copyId)
Creates a copy of the given property. Updates the id, creates independent copies of tagged values, the sequence number, type info, cardinality, as well as all attributes of primitive types. Does not update the objects (e.g. inClass or model) - they are used as-is and in order to be changed they need to be set separately.

Parameters:
pi -
copyId -
Returns:

remove

public void remove(Set<PackageInfo> packagesToRemove)
Removes all of the packages in the set from the model, including all classes contained in these packages. Also recursively removes all child packages of the given packages.

Parameters:
packagesToRemove -

dissolveAssociation

public void dissolveAssociation(GenericAssociationInfo genAI)
Basically turns the properties representing the two ends of an association into attributes of the classes they are in (unless the association end is not navigable). Removes the link between the properties that represent the ends of a given association. Each navigable property is kept in the model. A non-navigable property is removed. A reverse property reference as well as the reference from an end property to its association is (re-)set to null. Each property that is kept in the model is set to be an attribute, a composition, but no aggregation. Finally, the reference to the association is removed from the model. WARNING: a possibly existing association class is also removed from the model, with all its properties and links to other model elements!

Parameters:
genAI -

updateClassName

public void updateClassName(GenericClassInfo genCi,
                            String newName)
Replaces the current name of the class with the given name, applying the update in the model as well (superclasses, subtypes, model, and property type info).

Parameters:
newName -

packages

public HashSet<PackageInfo> packages()
Returns:
all PackageInfo objects contained in the model

removeByClassId

public void removeByClassId(String id)


Copyright © 2015. All rights reserved.