EDU.utwente.CoCompose.translate
Class SolutionPattern

java.lang.Object
  |
  +--EDU.utwente.CoCompose.translate.SolutionPattern
All Implemented Interfaces:
java.lang.Cloneable

public class SolutionPattern
extends java.lang.Object
implements java.lang.Cloneable

Represents a solution pattern for a Composite. It links to a file containing the actual solution pattern; i.e. a CoCompose model XML file.

Version:
0.1.20, 4 April 2004
Author:
Dennis Wagelaar

Field Summary
protected  Logger log
          Cached Logger object.
 
Constructor Summary
SolutionPattern()
          Constructs a SolutionPattern.
 
Method Summary
 void accept(ModelVisitor visitor)
          Accepts a ModelVisitor.
 void apply(Model model, Logger logger)
          Applies the solution pattern for the composite in the given model.
protected  void applyDP(Model model, Composite composite)
          Applies the solution pattern default part.
protected  void applyRP(Model model, Composite composite, CompositeRole role, Concept concept)
          Applies the solution pattern role part for the given concept.
 void copyAttributes(SolutionPattern fromSolution)
          Copies the attributes from the given solution pattern to self.
protected  void determineFilledBy(Model model, Composite composite, Model solutionModel)
          Determines the FilledBy property for each SolutionRole, if possible.
protected  SolutionRole findSolutionRole(java.lang.String name)
          Attempts to find the SolutionRole with the given name within the solution pattern.
 Composite getComposite()
          Gets the composite to which this solution pattern belongs.
 java.lang.String getFilename()
          Gets the name of the file that contains the actual solution pattern.
protected  java.util.Set getNamespaces(Model model)
          Gets the namespaces present in the given model.
protected  PublishedConcept getPublished(AbstractConcept concept)
          Retrieves the PublishedConcept that represents the given concept, if any.
protected  void linkAbstractConcept(Model model, Model solModel, AbstractConcept concept, AbstractConcept solConcept, AbstractConcept instantiatedBy)
          Links a new AbstractConcept according to the links in the solution model.
protected  void linkComposite(Model model, Model solModel, Composite composite, Composite solComposite, AbstractConcept instantiatedBy)
          Links a new Composite according to the links in the solution model.
protected  void linkPublished(Model model, Composite composite, PublishedConcept published, AbstractConcept concept)
          Links the solution pattern published concept into the model for the given concept.
protected  void linkRP(Model model, CompositeRole role, Concept concept)
          Links the solution pattern role part into the model for the given concept.
protected  Model loadSolutionModel()
          Loads the solution pattern model and returns it.
protected  void migrateImplementationConstraints(Model model, AbstractConcept source, AbstractConcept target)
          Migrates concept implementation constraints from the source concept to the target concept.
protected  void migratePublished(Model model, PublishedConcept published, Model solutionModel)
          Migrates the implementation constraints from the given published concept to the implementing concept.
 void setComposite(Composite composite)
          Sets the composite to which this solution pattern belongs.
 void setFilename(java.lang.String filename)
          Sets the name of the file that contains the actual solution pattern.
 void toXML(org.xml.sax.helpers.DefaultHandler handler)
          Create XML from this object using a SAX DefaultHandler.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected Logger log
Cached Logger object.
Constructor Detail

SolutionPattern

public SolutionPattern()
Constructs a SolutionPattern.
Method Detail

findSolutionRole

protected SolutionRole findSolutionRole(java.lang.String name)
                                 throws CoComposeException
Attempts to find the SolutionRole with the given name within the solution pattern.
Parameters:
name - - the SolutionRole name
Returns:
the SolutionRole, if found
Throws:
CoComposeException - if the SolutionRole is not found

getNamespaces

protected java.util.Set getNamespaces(Model model)
Gets the namespaces present in the given model.
Parameters:
model - - the model to look in.
Returns:
the set of UniqueRealm name strings that make up each namespace.

linkAbstractConcept

protected void linkAbstractConcept(Model model,
                                   Model solModel,
                                   AbstractConcept concept,
                                   AbstractConcept solConcept,
                                   AbstractConcept instantiatedBy)
                            throws CoComposeException
Links a new AbstractConcept according to the links in the solution model.
Parameters:
model - - the target model.
solModel - - the source (solution pattern) model.
concept - - the AbstractConcept to make links for.
solConcept - - the source AbstractConcept to read the links from.
instantiatedBy - - the concepts to link should be instantiated by the role part for this. Ignored if null.
Throws:
CoComposeException - - if one of the links could not be made.

linkComposite

protected void linkComposite(Model model,
                             Model solModel,
                             Composite composite,
                             Composite solComposite,
                             AbstractConcept instantiatedBy)
                      throws CoComposeException
Links a new Composite according to the links in the solution model. Links the roles as well.
Parameters:
model - - the target model.
solModel - - the source (solution pattern) model.
composite - - the Composite to make links for.
solComposite - - the source Composite to read the links from.
instantiatedBy - - the concepts to link should be instantiated by the role part for this. Ignored if null.
Throws:
CoComposeException - - if one of the links could not be made.

determineFilledBy

protected void determineFilledBy(Model model,
                                 Composite composite,
                                 Model solutionModel)
                          throws CoComposeException
Determines the FilledBy property for each SolutionRole, if possible. If a SolutionRole is filled by more than one Concept, then the FilledBy property will not be set.
Parameters:
model - - the model to solve to.
composite - - the composite being flattened.
solutionModel - - the model containing the solution pattern.
Throws:
CoComposeException - - if a solution role could not be found.

applyDP

protected void applyDP(Model model,
                       Composite composite)
                throws CoComposeException
Applies the solution pattern default part.
Parameters:
model - - the model to solve to.
composite - - the composite being flattened.
Throws:
CoComposeException - - if the default part could not be applied.

applyRP

protected void applyRP(Model model,
                       Composite composite,
                       CompositeRole role,
                       Concept concept)
                throws CoComposeException
Applies the solution pattern role part for the given concept.
Parameters:
model - - the model to solve to.
composite - - the composite being flattened.
role - - the role for which the role part will be applied.
concept - - the concept filling the role.
Throws:
CoComposeException - - if the role part could not be applied.

linkRP

protected void linkRP(Model model,
                      CompositeRole role,
                      Concept concept)
               throws CoComposeException
Links the solution pattern role part into the model for the given concept.
Parameters:
model - - the model to solve to.
role - - the role for which the role part will be applied.
concept - - the concept filling the role.
Throws:
CoComposeException - - if the role part could not be applied.

linkPublished

protected void linkPublished(Model model,
                             Composite composite,
                             PublishedConcept published,
                             AbstractConcept concept)
                      throws CoComposeException
Links the solution pattern published concept into the model for the given concept.
Parameters:
model - - the model to solve to.
composite - - the composite being flattened.
published - - the published concept to be replaced.
concept - - the concept linked to the published concept.
Throws:
CoComposeException - - if linking failed.

migratePublished

protected void migratePublished(Model model,
                                PublishedConcept published,
                                Model solutionModel)
                         throws CoComposeException
Migrates the implementation constraints from the given published concept to the implementing concept.
Parameters:
model - - the model to solve to.
published - - the published concept from which to migrate.
solutionModel - - the model containing the solution pattern.
Throws:
CoComposeException - - if migration failed.

migrateImplementationConstraints

protected void migrateImplementationConstraints(Model model,
                                                AbstractConcept source,
                                                AbstractConcept target)
                                         throws CoComposeException
Migrates concept implementation constraints from the source concept to the target concept.
Parameters:
model - - the model that is being transformed.
source - - the source concept to migrate from.
target - - the target concept.
Throws:
CoComposeException - - if migration failed.

loadSolutionModel

protected Model loadSolutionModel()
                           throws CoComposeException
Loads the solution pattern model and returns it.
Returns:
the model.
Throws:
CoComposeException - - if the model could not be loaded.

getPublished

protected PublishedConcept getPublished(AbstractConcept concept)
Retrieves the PublishedConcept that represents the given concept, if any.
Parameters:
concept - the concept that is represented by a published concept.
Returns:
the PublishedConcept that represents the given concept, if any.

getFilename

public java.lang.String getFilename()
Gets the name of the file that contains the actual solution pattern.
Returns:
the file name.

setFilename

public void setFilename(java.lang.String filename)
Sets the name of the file that contains the actual solution pattern.
Parameters:
filename - - the file name.

getComposite

public Composite getComposite()
Gets the composite to which this solution pattern belongs.
Returns:
the composite that owns this solution pattern.

setComposite

public void setComposite(Composite composite)
Sets the composite to which this solution pattern belongs.
Parameters:
composite - - the composite that owns this solution pattern.

copyAttributes

public void copyAttributes(SolutionPattern fromSolution)
Copies the attributes from the given solution pattern to self. It doesn't copy the composite link.
Parameters:
fromSolution - - the solution pattern to copy from.

toXML

public void toXML(org.xml.sax.helpers.DefaultHandler handler)
           throws org.xml.sax.SAXException
Create XML from this object using a SAX DefaultHandler.
Parameters:
handler - - the SAX DefaultHandler.
Throws:
org.xml.sax.SAXException - - if an XML handler error occurs.

apply

public void apply(Model model,
                  Logger logger)
           throws CoComposeException
Applies the solution pattern for the composite in the given model.
Parameters:
model - - the model context for the composite.
logger - - the object to log to.
Throws:
CoComposeException - - if the solution pattern cannot be applied.

accept

public void accept(ModelVisitor visitor)
            throws CoComposeException
Accepts a ModelVisitor.
Parameters:
visitor - - the visitor object to accept.
Throws:
CoComposeException - - if visiting operation failed.