EGF Engine
Release 0.1.0

org.eclipse.egf.model.data.helper
Class ModelHelper

java.lang.Object
  extended by org.eclipse.egf.model.data.helper.ModelHelper

public class ModelHelper
extends Object

Provides useful services based on model elements.


Constructor Summary
ModelHelper()
           
 
Method Summary
static FactoryComponentInvocation addFactoryComponentInvocation(FactoryComponent owningFC_p, String referencedFCId_p)
          Add a new factory component invocation to given FC.
static void addReferencingContractContextElement(Context context_p, String referencedFactoryComponentId_p, String referencedContractElementId_p, String value_p, String contributorId_p)
          Add a new context element (to given context) that references a contract element from another factory component.
static void addViewpointTypeId(String patternViewpointId_p, ViewpointType viewpointType_p, FactoryComponent factoryComponent_p)
          Add a viewpoint id in the specification of given factory component.
static ContractElementReference createContractElementReferenceBasedOn(ContractElement contractElement_p)
          Create a new contract element reference based on given contract element.
static FactoryComponent createEmptyMinimalFC(String factoryComponentName_p)
          Create a new Factory Component empty skeleton.
static MappingModel createMappingModel(String mappingRelativePath_p, String sourceFactoryComponentId_p, String targetFactoryComponentId_p, String mappingId_p)
          Create a new mapping model with given parameters.
static Contract getContract(FactoryComponent factoryComponent_p)
          Get the contract for given factory component.
static FactoryComponent getFactoryComponentContainer(NamedModelElementWithId modelElement_p)
          Get the factory component where given model element is a child of.
static FactoryComponent getFactoryComponentFrom(String factoryComponentName_p, Collection<FactoryComponent> factoryComponents_p)
          Get the factory component for specified factory component name in given fc collection.
static PatternLibrary getLibrary(String libraryId_p, PatternLibrary parentLibrary_p)
          Get a library for specified id in given library children.
static PatternLibrary getLibrary(String libraryId_p, PatternViewpoint patternViewpoint_p)
          Get a library for specified id in given pattern viewpoint.
static List<ContractElement> getMandatoryContractElement(FactoryComponent factoryComponent_p)
          Return a list of 'mandatory' contract element owned by specified factory component.
static MappingModel getMapping(String mappingId_p, List<MappingModel> mappings_p)
          Get a mapping model in given list for specified mapping id.
static List<MappingModel> getMappings(FactoryComponent factoryComponent_p)
          Get all mappings contained in given factory component.
static MappingViewpoint getMappingViewpoint(FactoryComponent factoryComponent_p)
          Get mapping viewpoint for given factory component.
static String getParentLibraryId(AbstractPatternElement patternElement_p)
          Return the id of the parent library id for specified pattern element.
static AbstractPatternElement getPatternElement(String shortPatternElementId_p, PatternLibrary parentLibrary_p)
          Get a first level child as AbstractPatternElement from given short pattern element id.
static String getPatternElementShortId(AbstractPatternElement patternElement_p)
          Return the short id of specified pattern element.
static PatternViewpoint getPatternViewpoint(FactoryComponent factoryComponent_p)
          Get the pattern viewpoint for given factory component.
static ProductionPlan getProductionPlan(FactoryComponent factoryComponent_p)
          Get the production plan for given factory component.
static IProject getProject(NamedModelElementWithId modelElement_p)
          Get the hosting project for given model element.
static  getViewpointTypeIds(Specification specification_p, ViewpointType viewpointType_p)
          Get the viewpoint ids for given specification and viewpoint type.
static boolean isDomainDefined(Domain domain_p)
          Is given domain defined ?
static void setContextType(ContextElement contextElement_p, String typeName_p)
          Set the context type for given type name.
static void setContractType(ContractElement contractElement_p, String typeName_p)
          Set the contract type for given type name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ModelHelper

public ModelHelper()
Method Detail

getFactoryComponentContainer

public static FactoryComponent getFactoryComponentContainer(NamedModelElementWithId modelElement_p)
Get the factory component where given model element is a child of.

Parameters:
modelElement_p -
Returns:
an FactoryComponent instance or null if not found.

getFactoryComponentFrom

public static FactoryComponent getFactoryComponentFrom(String factoryComponentName_p,
                                                       Collection<FactoryComponent> factoryComponents_p)
Get the factory component for specified factory component name in given fc collection.

Parameters:
factoryComponentName_p - the 'name' value of a factory component.
Returns:
an FactoryComponent instance or null if not found.

addViewpointTypeId

public static void addViewpointTypeId(String patternViewpointId_p,
                                      ViewpointType viewpointType_p,
                                      FactoryComponent factoryComponent_p)
Add a viewpoint id in the specification of given factory component.

Parameters:
patternViewpointId_p -
viewpointType_p -
factoryComponent_p -

getViewpointTypeIds

public static  getViewpointTypeIds(Specification specification_p,
                                        ViewpointType viewpointType_p)
Get the viewpoint ids for given specification and viewpoint type.

Parameters:
specification_p -
viewpointType_p -
Returns:
a no null list.

getContract

public static Contract getContract(FactoryComponent factoryComponent_p)
Get the contract for given factory component.

Parameters:
factoryComponent_p -
Returns:
a Contract instance or null if not defined.

getMandatoryContractElement

public static List<ContractElement> getMandatoryContractElement(FactoryComponent factoryComponent_p)
Return a list of 'mandatory' contract element owned by specified factory component.

Parameters:
factoryComponent_p -
Returns:
an empty list if no one found.

getPatternViewpoint

public static PatternViewpoint getPatternViewpoint(FactoryComponent factoryComponent_p)
Get the pattern viewpoint for given factory component.

Parameters:
factoryComponent_p -
Returns:
a PatternViewpoint instance or null if not defined.

getProductionPlan

public static ProductionPlan getProductionPlan(FactoryComponent factoryComponent_p)
Get the production plan for given factory component.

Parameters:
factoryComponent_p -
Returns:
a ProductionPlan instance or null if not defined.

setContractType

public static void setContractType(ContractElement contractElement_p,
                                   String typeName_p)
Set the contract type for given type name.

Parameters:
contractElement_p -
typeName_p -

setContextType

public static void setContextType(ContextElement contextElement_p,
                                  String typeName_p)
Set the context type for given type name.

Parameters:
contextElement_p -
typeName_p -

createContractElementReferenceBasedOn

public static ContractElementReference createContractElementReferenceBasedOn(ContractElement contractElement_p)
Create a new contract element reference based on given contract element.

Parameters:
contractElement_p -
Returns:
a ContractElementReference instance or null if given contract element is null.

getLibrary

public static PatternLibrary getLibrary(String libraryId_p,
                                        PatternViewpoint patternViewpoint_p)
Get a library for specified id in given pattern viewpoint.

Parameters:
libraryId_p -
patternViewpoint_p -
Returns:
null if not found.

getLibrary

public static PatternLibrary getLibrary(String libraryId_p,
                                        PatternLibrary parentLibrary_p)
Get a library for specified id in given library children.

Parameters:
libraryId_p -
parentLibrary_p -
Returns:
null if not found.

getPatternElementShortId

public static String getPatternElementShortId(AbstractPatternElement patternElement_p)
Return the short id of specified pattern element.
Given pattern element is either a PatternLibrary or a PatternModel element.
In case of a pattern library (as a child of another one) or a pattern model, return string is the final part after the trailing '/' character.
In case of a 'root' library, return string is the same as the full id. IPatternConstants.LIBRARY_PATTERN_ID_SEPARATOR

Parameters:
patternElement_p -
Returns:
the short id
See Also:
IPatternExtensionConstants#LIBRARY_PATTERN_ID_SEPARATOR.

getParentLibraryId

public static String getParentLibraryId(AbstractPatternElement patternElement_p)
Return the id of the parent library id for specified pattern element.

Parameters:
patternElement_p -
Returns:
null if given pattern element is a 'root' library ie, this kind of library do not have a parent.
A 'root' pattern library is a library which has a pattern viewpoint as parent.

getPatternElement

public static AbstractPatternElement getPatternElement(String shortPatternElementId_p,
                                                       PatternLibrary parentLibrary_p)
Get a first level child as AbstractPatternElement from given short pattern element id.

Parameters:
shortPatternElementId_p -
parentLibrary_p -
Returns:
null if not found or an AbstractPatternElement element.

isDomainDefined

public static boolean isDomainDefined(Domain domain_p)
Is given domain defined ?

Parameters:
domain_p -
Returns:
true if the given domain has a path.

getMappings

public static List<MappingModel> getMappings(FactoryComponent factoryComponent_p)
Get all mappings contained in given factory component.

Parameters:
factoryComponent_p -
Returns:
a not null list.

getMappingViewpoint

public static MappingViewpoint getMappingViewpoint(FactoryComponent factoryComponent_p)
Get mapping viewpoint for given factory component.

Parameters:
factoryComponent_p -
Returns:

createEmptyMinimalFC

public static FactoryComponent createEmptyMinimalFC(String factoryComponentName_p)
Create a new Factory Component empty skeleton.
It is made of a factory component, a factory and a default production plan.

Parameters:
factoryComponentName_p -
Returns:
The Factory Component new instance (known as an FactoryComponent at the model level).

addFactoryComponentInvocation

public static FactoryComponentInvocation addFactoryComponentInvocation(FactoryComponent owningFC_p,
                                                                       String referencedFCId_p)
Add a new factory component invocation to given FC.
The new configuration is empty and referencing identified FC.
It does not have a context or a task factory.
Note the the new configuration is inserted at the end of production plan.

Parameters:
owningFC_p - The FC that is declaring the new factory component invocation, ie using it in its factory.
referencedFCId_p - The FC pointed by the factory component invocation, ie implied in the execute of owner one.
Returns:

addReferencingContractContextElement

public static void addReferencingContractContextElement(Context context_p,
                                                        String referencedFactoryComponentId_p,
                                                        String referencedContractElementId_p,
                                                        String value_p,
                                                        String contributorId_p)
Add a new context element (to given context) that references a contract element from another factory component.

Parameters:
context_p - The context being filled up.
referencedFactoryComponentId_p - The factory component declaring the contract.
referencedContractElementId_p - A contract element from this 'remote' contract.
value_p - The context element value according to the contract element. No check is done here, so there may be a runtime error if the value does not conform to the contract element declared type.
contributorId_p - The plug-in id that contributes the context.

createMappingModel

public static MappingModel createMappingModel(String mappingRelativePath_p,
                                              String sourceFactoryComponentId_p,
                                              String targetFactoryComponentId_p,
                                              String mappingId_p)
Create a new mapping model with given parameters.

Parameters:
mappingRelativePath_p -
sourceFactoryComponentId_p -
targetFactoryComponentId_p -
mappingId_p -
Returns:
null if relative path is null.

getMapping

public static MappingModel getMapping(String mappingId_p,
                                      List<MappingModel> mappings_p)
Get a mapping model in given list for specified mapping id.

Parameters:
mappingId_p -
mappings_p -
Returns:
a MappingModel instance or null if not found.

getProject

public static IProject getProject(NamedModelElementWithId modelElement_p)
Get the hosting project for given model element.
It means the project where the factory component container of given model element is defined.

Parameters:
modelElement_p -
Returns:
an IProject instance if given model element is contained by a factory component located in the workspace; null otherwise.

EGF Engine
Release 0.1.0

Copyright (c) Thales Corporate Services S.A.S, 2009.

This page is made available under license. For full details see the LEGAL in the documentation book that contains this page.