Package com._1c.g5.v8.dt.md.copy
Class AttachingModelObjectCopier
- java.lang.Object
-
- com._1c.g5.v8.dt.md.copy.ModelObjectCopier
-
- com._1c.g5.v8.dt.md.copy.AttachingModelObjectCopier
-
public class AttachingModelObjectCopier extends ModelObjectCopier
Model object copier that also attaches copied objects to the provided BM session. All created copy objects will be attached to that session. External properties will be copied as file system resources. Copier allows to copy metadata objects to different target classes, e.g. clients may copyDocument
toCatalog
, or even toCatalogAttribute
and only matching attributes will be copied.AttachingModelObjectCopier
instances are stateful, they hold information about BM session to attach objects to.AttachingModelObjectCopier
may be used multiple times to copy and attach multiple objects to the same BM session.Clients may extend copier and customize copy and attach process.
- See Also:
ModelObjectCopier
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
AttachingModelObjectCopier.SharedCopyContext
The shared context for copy process that holds information about copied objects, references, names, etc., and also is intended to be shared between copy invocations.-
Nested classes/interfaces inherited from class com._1c.g5.v8.dt.md.copy.ModelObjectCopier
ModelObjectCopier.CopyContext
-
-
Field Summary
Fields Modifier and Type Field Description protected IBmEmfIndexProvider
bmEmfIndexProvider
protected IBmModel
bmModel
protected IBmModelManager
bmModelManager
protected AttachingModelObjectCopier.SharedCopyContext
context
protected IProjectFileSystemSupportProvider
projectFileSystemSupportProvider
protected org.eclipse.xtext.naming.IQualifiedNameProvider
qualifiedNameProvider
protected IResourceLookup
resourceLookup
protected ISymbolicNameService
symbolicNameService
protected ITopObjectFqnGenerator
topObjectFqnGenerator
protected IBmTransaction
transaction
-
Fields inherited from class com._1c.g5.v8.dt.md.copy.ModelObjectCopier
editingLanguageManager, modelFactory, PRODUCED_TYPES_FEATURE_NAME, runtimeVersionSupport, v8projectManager
-
-
Constructor Summary
Constructors Constructor Description AttachingModelObjectCopier(IV8ProjectManager v8projectManager, IModelObjectFactory modelFactory, IRuntimeVersionSupport runtimeVersionSupport, IEditingLanguageManager editingLanguageManager, ITopObjectFqnGenerator topObjectFqnGenerator, org.eclipse.xtext.naming.IQualifiedNameProvider qualifiedNameProvider, IResourceLookup resourceLookup, IProjectFileSystemSupportProvider projectFileSystemSupportProvider, IBmModelManager bmModelManager, IBmEmfIndexManager bmEmfIndexManager, ISymbolicNameService symbolicNameService, IBmTransaction transaction, IBmModel bmModel)
Constructor ofAttachingModelObjectCopier
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected org.eclipse.emf.ecore.EObject
attach(org.eclipse.emf.ecore.EObject copy, org.eclipse.emf.ecore.EObject parent, org.eclipse.emf.ecore.EReference reference)
Attach the result model object copy using the providedparent
object reference.protected <T extends IBmObject>
TattachExternalProperty(T externalProperty, org.eclipse.emf.ecore.EObject owner, org.eclipse.emf.ecore.EReference reference)
Attach the given external property to the associated BM session.protected <T extends IBmObject>
TattachModelObject(T original)
Attach the given model object to the associated BM session.protected <T extends IBmObject>
TattachModelObject(T original, boolean isTop)
Attach the given model object to the associated BM session.protected void
copyExternalPropertyReference(org.eclipse.emf.ecore.EObject fromObject, org.eclipse.emf.ecore.EReference fromReference, org.eclipse.emf.ecore.EObject toObject, org.eclipse.emf.ecore.EReference toReference, ModelObjectCopier.CopyContext context, boolean resolveProxies, boolean useOriginalReferences)
Copy the model object external property reference feature.protected void
copyExternalPropertyResource(ModelObjectCopier.CopyContext context, org.eclipse.core.resources.IProject projectFrom, org.eclipse.core.resources.IProject projectTo, IProjectFileSystemSupport projectFileSystemSupportTo, IProjectFileSystemSupport projectFileSystemSupportFrom, org.eclipse.emf.ecore.EObject owner, org.eclipse.emf.ecore.EReference reference, org.eclipse.emf.ecore.EObject externalProperty)
Copies the provided external property resource file to the target file location and attaches it to the associated BM session.protected void
copyReference(org.eclipse.emf.ecore.EObject fromObject, org.eclipse.emf.ecore.EReference fromReference, org.eclipse.emf.ecore.EObject toObject, org.eclipse.emf.ecore.EReference toReference, ModelObjectCopier.CopyContext context, boolean resolveProxies, boolean useOriginalReferences)
Copy the model object non-containment reference feature.protected Object
copyReferenceAsProxy(org.eclipse.core.resources.IProject fromProject, org.eclipse.emf.ecore.EObject fromObject, org.eclipse.emf.ecore.EReference fromReference, org.eclipse.core.resources.IProject toProject, org.eclipse.emf.ecore.EObject toObject, org.eclipse.emf.ecore.EReference toReference, ModelObjectCopier.CopyContext context)
Copy the model object non-containment reference feature as proxy in the associated BM session project.protected void
copyReferenceField(org.eclipse.emf.ecore.EObject fromObject, org.eclipse.emf.ecore.EReference fromReference, org.eclipse.emf.ecore.EObject toObject, org.eclipse.emf.ecore.EReference toReference, ModelObjectCopier.CopyContext context, boolean resolveProxies, boolean useOriginalReferences)
Copy the model object non-containment reference feature of theField
type.protected void
copyReferenceFields(org.eclipse.emf.ecore.EObject fromObject, org.eclipse.emf.ecore.EReference fromReference, org.eclipse.emf.ecore.EObject toObject, org.eclipse.emf.ecore.EReference toReference, ModelObjectCopier.CopyContext context, boolean resolveProxies, boolean useOriginalReferences)
Copy the model object non-containment reference feature of theField
type.protected void
copyReferences(ModelObjectCopier.CopyContext context, org.eclipse.emf.ecore.EObject parent, boolean resolveProxies, boolean useOriginalReferences)
Copy all references in the providedCopyContext
copies.protected void
copyReferenceTypeDescription(TypeDescription typeDescription, org.eclipse.emf.ecore.EReference fromReference, org.eclipse.emf.ecore.EObject copyEObject, org.eclipse.emf.ecore.EReference toReference, ModelObjectCopier.CopyContext context, boolean resolveProxies, boolean useOriginalReferences)
Copy the model object non-containment reference feature from the type description object.protected void
copyResource(org.eclipse.core.resources.IFile fromFile, org.eclipse.core.resources.IFile toFile)
Copies the provided resource file to the target file location.protected void
copySourceAsReferenceType(org.eclipse.emf.ecore.EObject eObject, org.eclipse.emf.ecore.EObject copyObject, org.eclipse.emf.ecore.EReference toReference, ModelObjectCopier.CopyContext context)
Copy the source object as reference to source type in the terms of V8 metadata model.protected ModelObjectCopier.CopyContext
createContext(org.eclipse.emf.ecore.EClass toClass)
Creates copy context.protected ModelObjectCopier.CopyContext
createContext(org.eclipse.emf.ecore.EObject parent, org.eclipse.emf.ecore.EReference reference)
Creates copy context.protected org.eclipse.emf.ecore.EObject
createProxy(org.eclipse.core.resources.IProject sourceProject, org.eclipse.emf.ecore.EObject sourceParent, org.eclipse.emf.ecore.EObject source, org.eclipse.core.resources.IProject targetProject, org.eclipse.emf.ecore.EObject targetParent, org.eclipse.emf.ecore.EReference targetReference, ModelObjectCopier.CopyContext context)
Create proxy of the source object in the target project.protected String
generateExternalPropertyFqn(IBmObject externalProperty, org.eclipse.emf.ecore.EObject owner, org.eclipse.emf.ecore.EReference reference)
Generate and external property FQN.protected String
generateMdCopyName(MdObject sourceObject, MdObject targetObject, org.eclipse.emf.ecore.EObject targetParent, org.eclipse.emf.ecore.EReference reference, ModelObjectCopier.CopyContext copyContext)
Generate copied model metadata object name.-
Methods inherited from class com._1c.g5.v8.dt.md.copy.ModelObjectCopier
copy, copy, copy, copy, copyAccountingFlag, copyAttribute, copyAttributeValue, copyCollection, copyContainment, copyExternalDataSourceSubObjects, copyFeatureMap, copyHelp, copyMdName, copyReferences, copyReferenceSubsystem, createCopy, getName, getTarget, getTarget, isChanged, isExternalProperty, isFormReference, isGraphicalSchemeReference, isHtmlDocumentTemplateReference, isNotAnnotatedExternalResource, isRightsReference, isStyleReference, nameExists, shouldCopyAttribute, shouldCopyContainment, shouldCopyExternalPropertyReference, shouldCopyReference
-
-
-
-
Field Detail
-
topObjectFqnGenerator
protected final ITopObjectFqnGenerator topObjectFqnGenerator
-
qualifiedNameProvider
protected final org.eclipse.xtext.naming.IQualifiedNameProvider qualifiedNameProvider
-
resourceLookup
protected final IResourceLookup resourceLookup
-
projectFileSystemSupportProvider
protected final IProjectFileSystemSupportProvider projectFileSystemSupportProvider
-
bmModelManager
protected final IBmModelManager bmModelManager
-
bmEmfIndexProvider
protected final IBmEmfIndexProvider bmEmfIndexProvider
-
transaction
protected final IBmTransaction transaction
-
bmModel
protected final IBmModel bmModel
-
symbolicNameService
protected final ISymbolicNameService symbolicNameService
-
context
protected final AttachingModelObjectCopier.SharedCopyContext context
-
-
Constructor Detail
-
AttachingModelObjectCopier
public AttachingModelObjectCopier(IV8ProjectManager v8projectManager, IModelObjectFactory modelFactory, IRuntimeVersionSupport runtimeVersionSupport, IEditingLanguageManager editingLanguageManager, ITopObjectFqnGenerator topObjectFqnGenerator, org.eclipse.xtext.naming.IQualifiedNameProvider qualifiedNameProvider, IResourceLookup resourceLookup, IProjectFileSystemSupportProvider projectFileSystemSupportProvider, IBmModelManager bmModelManager, IBmEmfIndexManager bmEmfIndexManager, ISymbolicNameService symbolicNameService, IBmTransaction transaction, IBmModel bmModel)
Constructor ofAttachingModelObjectCopier
.- Parameters:
v8projectManager
- the V8 project manager, cannot benull
modelFactory
- the model object factory, cannot benull
runtimeVersionSupport
- the 1C:Enterprise runtime version support, cannot benull
editingLanguageManager
- the editing language manager, cannot benull
topObjectFqnGenerator
- the top object FQN generator, cannot benull
qualifiedNameProvider
- the qualified name provider, cannot benull
resourceLookup
- the resource lookup, cannot benull
projectFileSystemSupportProvider
- the project filesystem support provider, cannot benull
bmModelManager
- the BM model manager, cannot benull
bmEmfIndexManager
- the BM model EMF index manager, cannot benull
transaction
- the transaction to perform copying within, cannot benull
bmModel
- the target BM model, cannot benull
symbolicNameService
- symbolic name service for gettingURI
, can't benull
-
-
Method Detail
-
attach
protected org.eclipse.emf.ecore.EObject attach(org.eclipse.emf.ecore.EObject copy, org.eclipse.emf.ecore.EObject parent, org.eclipse.emf.ecore.EReference reference)
Attach the result model object copy using the providedparent
object reference. Returns attached object. Method is called after source object copy and before its references copy.Attaching copier implementation also attaches result object copy to the BM session.
- Overrides:
attach
in classModelObjectCopier
- Parameters:
copy
- the model object copy to attach, cannot benull
parent
- the target parent, cannot benull
reference
- the parent reference, cannot benull
- Returns:
- the attached object, never
null
-
copyReferences
protected void copyReferences(ModelObjectCopier.CopyContext context, org.eclipse.emf.ecore.EObject parent, boolean resolveProxies, boolean useOriginalReferences)
Copy all references in the providedCopyContext
copies.Attaching copier implementation copies references as superclass implementation and also copies referenced external property filesystem resources.
- Overrides:
copyReferences
in classModelObjectCopier
- Parameters:
context
- the copy context, cannot benull
parent
- the parent, can benull
resolveProxies
- whether proxies should be resolved while copyinguseOriginalReferences
- whether non-copied references should be used while copying
-
copyReference
protected void copyReference(org.eclipse.emf.ecore.EObject fromObject, org.eclipse.emf.ecore.EReference fromReference, org.eclipse.emf.ecore.EObject toObject, org.eclipse.emf.ecore.EReference toReference, ModelObjectCopier.CopyContext context, boolean resolveProxies, boolean useOriginalReferences)
Description copied from class:ModelObjectCopier
Copy the model object non-containment reference feature.- Overrides:
copyReference
in classModelObjectCopier
- Parameters:
fromObject
- the object to copy reference feature from, cannot benull
fromReference
- the reference feature to copy, cannot benull
toObject
- the object to copy reference feature to, cannot benull
toReference
- the reference feature to copy, cannot benull
context
- the copy context, cannot benull
resolveProxies
- whether proxies should be resolved while copyinguseOriginalReferences
- whether non-copied references should be used while copying
-
copyExternalPropertyReference
protected void copyExternalPropertyReference(org.eclipse.emf.ecore.EObject fromObject, org.eclipse.emf.ecore.EReference fromReference, org.eclipse.emf.ecore.EObject toObject, org.eclipse.emf.ecore.EReference toReference, ModelObjectCopier.CopyContext context, boolean resolveProxies, boolean useOriginalReferences)
Description copied from class:ModelObjectCopier
Copy the model object external property reference feature.- Overrides:
copyExternalPropertyReference
in classModelObjectCopier
- Parameters:
fromObject
- the object to copy external property from, cannot benull
fromReference
- the external property to copy, cannot benull
toObject
- the object to copy external property to, cannot benull
toReference
- the external property to copy to, cannot benull
context
- the copy context, cannot benull
resolveProxies
- whether proxies should be resolved while copyinguseOriginalReferences
- whether non-copied references should be used while copying
-
generateMdCopyName
protected String generateMdCopyName(MdObject sourceObject, MdObject targetObject, org.eclipse.emf.ecore.EObject targetParent, org.eclipse.emf.ecore.EReference reference, ModelObjectCopier.CopyContext copyContext)
Description copied from class:ModelObjectCopier
Generate copied model metadata object name.- Overrides:
generateMdCopyName
in classModelObjectCopier
- Parameters:
sourceObject
- the source object to copy, cannot benull
targetObject
- the target object to copy, cannot benull
targetParent
- the target parent to copy to ornull
if nonereference
- the parent reference to copy to ornull
if none- Returns:
- the copied model metadata object name, never
null
-
copyReferenceTypeDescription
protected void copyReferenceTypeDescription(TypeDescription typeDescription, org.eclipse.emf.ecore.EReference fromReference, org.eclipse.emf.ecore.EObject copyEObject, org.eclipse.emf.ecore.EReference toReference, ModelObjectCopier.CopyContext context, boolean resolveProxies, boolean useOriginalReferences)
Description copied from class:ModelObjectCopier
Copy the model object non-containment reference feature from the type description object.- Overrides:
copyReferenceTypeDescription
in classModelObjectCopier
- Parameters:
typeDescription
- the object to copy reference feature from, cannot benull
fromReference
- the reference feature to copy, cannot benull
toReference
- the reference feature to copy, cannot benull
context
- the copy context, cannot benull
resolveProxies
- whether proxies should be resolved while copyinguseOriginalReferences
- whether non-copied references should be used while copying
-
copyReferenceFields
protected void copyReferenceFields(org.eclipse.emf.ecore.EObject fromObject, org.eclipse.emf.ecore.EReference fromReference, org.eclipse.emf.ecore.EObject toObject, org.eclipse.emf.ecore.EReference toReference, ModelObjectCopier.CopyContext context, boolean resolveProxies, boolean useOriginalReferences)
Description copied from class:ModelObjectCopier
Copy the model object non-containment reference feature of theField
type.- Overrides:
copyReferenceFields
in classModelObjectCopier
- Parameters:
fromObject
- the object to copy reference feature from, cannot benull
fromReference
- the reference feature to copy, cannot benull
toObject
- the object to copy reference feature to, cannot benull
toReference
- the reference feature to copy, cannot benull
context
- the copy context, cannot benull
resolveProxies
- whether proxies should be resolved while copyinguseOriginalReferences
- whether non-copied references should be used while copying
-
copyReferenceField
protected void copyReferenceField(org.eclipse.emf.ecore.EObject fromObject, org.eclipse.emf.ecore.EReference fromReference, org.eclipse.emf.ecore.EObject toObject, org.eclipse.emf.ecore.EReference toReference, ModelObjectCopier.CopyContext context, boolean resolveProxies, boolean useOriginalReferences)
Description copied from class:ModelObjectCopier
Copy the model object non-containment reference feature of theField
type.- Overrides:
copyReferenceField
in classModelObjectCopier
- Parameters:
fromObject
- the object to copy reference feature from, cannot benull
fromReference
- the reference feature to copy, cannot benull
toObject
- the object to copy reference feature to, cannot benull
toReference
- the reference feature to copy, cannot benull
context
- the copy context, cannot benull
resolveProxies
- whether proxies should be resolved while copyinguseOriginalReferences
- whether non-copied references should be used while copying
-
copySourceAsReferenceType
protected void copySourceAsReferenceType(org.eclipse.emf.ecore.EObject eObject, org.eclipse.emf.ecore.EObject copyObject, org.eclipse.emf.ecore.EReference toReference, ModelObjectCopier.CopyContext context)
Description copied from class:ModelObjectCopier
Copy the source object as reference to source type in the terms of V8 metadata model. If cannot copy then do nothing.- Overrides:
copySourceAsReferenceType
in classModelObjectCopier
- Parameters:
eObject
- the original object, cannot benull
copyObject
- the copied object, cannot benull
toReference
- the type description reference to copy source as type to, cannot benull
context
- the copy context, cannot benull
-
createContext
protected ModelObjectCopier.CopyContext createContext(org.eclipse.emf.ecore.EClass toClass)
Description copied from class:ModelObjectCopier
Creates copy context. Subclasses may override and provide more specific copy context.- Overrides:
createContext
in classModelObjectCopier
- Parameters:
toClass
- the result model class, cannot benull
- Returns:
- the created copy context, never
null
-
createContext
protected ModelObjectCopier.CopyContext createContext(org.eclipse.emf.ecore.EObject parent, org.eclipse.emf.ecore.EReference reference)
Description copied from class:ModelObjectCopier
Creates copy context. Subclasses may override and provide more specific copy context.- Overrides:
createContext
in classModelObjectCopier
- Parameters:
parent
- the target parent, cannot benull
reference
- the reference parent, cannot benull
- Returns:
- the created copy context, never
null
-
attachExternalProperty
protected <T extends IBmObject> T attachExternalProperty(T externalProperty, org.eclipse.emf.ecore.EObject owner, org.eclipse.emf.ecore.EReference reference)
Attach the given external property to the associated BM session.- Parameters:
externalProperty
- the external property value, cannot benull
owner
- the external property owner, cannot benull
reference
- the external property reference, cannot benull
- Returns:
- the attached external property, never
null
-
attachModelObject
protected <T extends IBmObject> T attachModelObject(T original)
Attach the given model object to the associated BM session.- Parameters:
original
- the original model object, cannot benull
- Returns:
- the attached model object, never
null
-
attachModelObject
protected <T extends IBmObject> T attachModelObject(T original, boolean isTop)
Attach the given model object to the associated BM session.- Parameters:
original
- the original model object, cannot benull
isTop
- whether the object is top object- Returns:
- the attached model object, never
null
-
createProxy
protected org.eclipse.emf.ecore.EObject createProxy(org.eclipse.core.resources.IProject sourceProject, org.eclipse.emf.ecore.EObject sourceParent, org.eclipse.emf.ecore.EObject source, org.eclipse.core.resources.IProject targetProject, org.eclipse.emf.ecore.EObject targetParent, org.eclipse.emf.ecore.EReference targetReference, ModelObjectCopier.CopyContext context)
Create proxy of the source object in the target project. The proxy will have the same URI but with the providedproject
instead of original and the providedtargetParent
URI part instead ofsourceParent
part.- Parameters:
sourceProject
- the source object project, cannot benull
sourceParent
- the source object parent, cannot benull
source
- the source object, cannot benull
targetProject
- the target project to create proxy in, cannot benull
targetParent
- the target proxy object parent, cannot benull
targetReference
- the target proxy reference, cannot benull
context
- the copy context, cannot benull
- Returns:
- the created proxy, never
null
-
copyExternalPropertyResource
protected void copyExternalPropertyResource(ModelObjectCopier.CopyContext context, org.eclipse.core.resources.IProject projectFrom, org.eclipse.core.resources.IProject projectTo, IProjectFileSystemSupport projectFileSystemSupportTo, IProjectFileSystemSupport projectFileSystemSupportFrom, org.eclipse.emf.ecore.EObject owner, org.eclipse.emf.ecore.EReference reference, org.eclipse.emf.ecore.EObject externalProperty)
Copies the provided external property resource file to the target file location and attaches it to the associated BM session.- Parameters:
context
- the copy context, cannot benull
projectFrom
- the project to copy resource from, cannot benull
projectTo
- the project to copy resource to, cannot benull
projectFileSystemSupportTo
- the project filesystem support to copy resource from, cannot benull
projectFileSystemSupportFrom
- the project filesystem support to copy resource to, cannot benull
owner
- the external property owner, cannot benull
reference
- the external property reference feature, cannot benull
externalProperty
- the external property, cannot benull
-
copyReferenceAsProxy
protected Object copyReferenceAsProxy(org.eclipse.core.resources.IProject fromProject, org.eclipse.emf.ecore.EObject fromObject, org.eclipse.emf.ecore.EReference fromReference, org.eclipse.core.resources.IProject toProject, org.eclipse.emf.ecore.EObject toObject, org.eclipse.emf.ecore.EReference toReference, ModelObjectCopier.CopyContext context)
Copy the model object non-containment reference feature as proxy in the associated BM session project.- Parameters:
fromProject
- the original object project, cannot benull
fromObject
- the object to copy reference feature from, cannot benull
fromReference
- the reference feature to copy, cannot benull
toProject
- the project to create proxy in, cannot benull
toObject
- the object to copy reference feature to, cannot benull
toReference
- the reference feature to copy, cannot benull
context
- the copy context, cannot benull
resolveProxies
- whether proxies should be resolved while copyinguseOriginalReferences
- whether non-copied references should be used while copying- Returns:
- the result of the copied reference:
EObject
element or a collection ofEObject
elements, nevernull
-
copyResource
protected void copyResource(org.eclipse.core.resources.IFile fromFile, org.eclipse.core.resources.IFile toFile)
Copies the provided resource file to the target file location. If target file is already exist it will be replaced with the provided file copy.- Parameters:
fromFile
- the source file to copy, cannot benull
toFile
- the target file location, cannot benull
-
generateExternalPropertyFqn
protected String generateExternalPropertyFqn(IBmObject externalProperty, org.eclipse.emf.ecore.EObject owner, org.eclipse.emf.ecore.EReference reference)
Generate and external property FQN.- Parameters:
externalProperty
- the external property object, cannot benull
owner
- the external property owner, cannot benull
reference
- the reference to external property, cannot benull
- Returns:
- the generated external property FQN, never
null
-
-