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
- Direct Known Subclasses:
FormExtender
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 copy
Document
to Catalog, or even to CatalogAttribute 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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassThe 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
FieldsModifier and TypeFieldDescriptionprotected final IBmEmfIndexProviderprotected final IBmModelprotected final IBmModelManagerprotected final AttachingModelObjectCopier.SharedCopyContextprotected final IProjectFileSystemSupportProviderprotected final org.eclipse.xtext.naming.IQualifiedNameProviderprotected final IResourceLookupprotected final ISymbolicNameServiceprotected final ITopObjectFqnGeneratorprotected final IBmTransactionFields inherited from class com._1c.g5.v8.dt.md.copy.ModelObjectCopier
editingLanguageManager, modelFactory, PRODUCED_TYPES_FEATURE_NAME, runtimeVersionSupport, v8projectManager -
Constructor Summary
ConstructorsConstructorDescriptionAttachingModelObjectCopier(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
Modifier and TypeMethodDescriptionprotected org.eclipse.emf.ecore.EObjectattach(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 providedparentobject 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 voidcopyExternalPropertyReference(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 voidcopyExternalPropertyResource(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 voidcopyReference(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 ObjectcopyReferenceAsProxy(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 voidcopyReferenceField(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 theFieldtype.protected voidcopyReferenceFields(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 theFieldtype.protected voidcopyReferences(ModelObjectCopier.CopyContext context, org.eclipse.emf.ecore.EObject parent, boolean resolveProxies, boolean useOriginalReferences) Copy all references in the providedCopyContextcopies.protected voidcopyReferenceTypeDescription(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 voidcopyResource(org.eclipse.core.resources.IFile fromFile, org.eclipse.core.resources.IFile toFile) Copies the provided resource file to the target file location.protected voidcopySourceAsReferenceType(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.CopyContextcreateContext(org.eclipse.emf.ecore.EClass toClass) Creates copy context.protected ModelObjectCopier.CopyContextcreateContext(org.eclipse.emf.ecore.EObject parent, org.eclipse.emf.ecore.EReference reference) Creates copy context.protected org.eclipse.emf.ecore.EObjectcreateProxy(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 StringgenerateExternalPropertyFqn(IBmObject externalProperty, org.eclipse.emf.ecore.EObject owner, org.eclipse.emf.ecore.EReference reference) Generate and external property FQN.protected StringgenerateMdCopyName(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, isAdditionalIndexesReference, isChanged, isExternalProperty, isFormReference, isGraphicalSchemeReference, isHtmlDocumentTemplateReference, isNotAnnotatedExternalResource, isProxyAdditionalIndexesReference, isRightsReference, isStyleReference, nameExists, shouldCopyAttribute, shouldCopyContainment, shouldCopyExternalPropertyReference, shouldCopyReference
-
Field Details
-
topObjectFqnGenerator
-
qualifiedNameProvider
protected final org.eclipse.xtext.naming.IQualifiedNameProvider qualifiedNameProvider -
resourceLookup
-
projectFileSystemSupportProvider
-
bmModelManager
-
bmEmfIndexProvider
-
transaction
-
bmModel
-
symbolicNameService
-
context
-
-
Constructor Details
-
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 benullmodelFactory- the model object factory, cannot benullruntimeVersionSupport- the 1C:Enterprise runtime version support, cannot benulleditingLanguageManager- the editing language manager, cannot benulltopObjectFqnGenerator- the top object FQN generator, cannot benullqualifiedNameProvider- the qualified name provider, cannot benullresourceLookup- the resource lookup, cannot benullprojectFileSystemSupportProvider- the project filesystem support provider, cannot benullbmModelManager- the BM model manager, cannot benullbmEmfIndexManager- the BM model EMF index manager, cannot benulltransaction- the transaction to perform copying within, cannot benullbmModel- the target BM model, cannot benullsymbolicNameService- symbolic name service for gettingURI, can't benull
-
-
Method Details
-
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 providedparentobject 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:
attachin classModelObjectCopier- Parameters:
copy- the model object copy to attach, cannot benullparent- the target parent, cannot benullreference- 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 providedCopyContextcopies.Attaching copier implementation copies references as superclass implementation and also copies referenced external property filesystem resources.
- Overrides:
copyReferencesin classModelObjectCopier- Parameters:
context- the copy context, cannot benullparent- the parent, can benullresolveProxies- 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:ModelObjectCopierCopy the model object non-containment reference feature.- Overrides:
copyReferencein classModelObjectCopier- Parameters:
fromObject- the object to copy reference feature from, cannot benullfromReference- the reference feature to copy, cannot benulltoObject- the object to copy reference feature to, cannot benulltoReference- the reference feature to copy, cannot benullcontext- the copy context, cannot benullresolveProxies- 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:ModelObjectCopierCopy the model object external property reference feature.- Overrides:
copyExternalPropertyReferencein classModelObjectCopier- Parameters:
fromObject- the object to copy external property from, cannot benullfromReference- the external property to copy, cannot benulltoObject- the object to copy external property to, cannot benulltoReference- the external property to copy to, cannot benullcontext- the copy context, cannot benullresolveProxies- 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:ModelObjectCopierGenerate copied model metadata object name.- Overrides:
generateMdCopyNamein classModelObjectCopier- Parameters:
sourceObject- the source object to copy, cannot benulltargetObject- the target object to copy, cannot benulltargetParent- the target parent to copy to ornullif nonereference- the parent reference to copy to ornullif 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:ModelObjectCopierCopy the model object non-containment reference feature from the type description object.- Overrides:
copyReferenceTypeDescriptionin classModelObjectCopier- Parameters:
typeDescription- the object to copy reference feature from, cannot benullfromReference- the reference feature to copy, cannot benulltoReference- the reference feature to copy, cannot benullcontext- the copy context, cannot benullresolveProxies- 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:ModelObjectCopierCopy the model object non-containment reference feature of theFieldtype.- Overrides:
copyReferenceFieldsin classModelObjectCopier- Parameters:
fromObject- the object to copy reference feature from, cannot benullfromReference- the reference feature to copy, cannot benulltoObject- the object to copy reference feature to, cannot benulltoReference- the reference feature to copy, cannot benullcontext- the copy context, cannot benullresolveProxies- 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:ModelObjectCopierCopy the model object non-containment reference feature of theFieldtype.- Overrides:
copyReferenceFieldin classModelObjectCopier- Parameters:
fromObject- the object to copy reference feature from, cannot benullfromReference- the reference feature to copy, cannot benulltoObject- the object to copy reference feature to, cannot benulltoReference- the reference feature to copy, cannot benullcontext- the copy context, cannot benullresolveProxies- 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:ModelObjectCopierCopy the source object as reference to source type in the terms of V8 metadata model. If cannot copy then do nothing.- Overrides:
copySourceAsReferenceTypein classModelObjectCopier- Parameters:
eObject- the original object, cannot benullcopyObject- the copied object, cannot benulltoReference- the type description reference to copy source as type to, cannot benullcontext- the copy context, cannot benull
-
createContext
Description copied from class:ModelObjectCopierCreates copy context. Subclasses may override and provide more specific copy context.- Overrides:
createContextin 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:ModelObjectCopierCreates copy context. Subclasses may override and provide more specific copy context.- Overrides:
createContextin classModelObjectCopier- Parameters:
parent- the target parent, cannot benullreference- 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 benullowner- the external property owner, cannot benullreference- the external property reference, cannot benull- Returns:
- the attached external property, never
null
-
attachModelObject
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
Attach the given model object to the associated BM session.- Parameters:
original- the original model object, cannot benullisTop- 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 providedprojectinstead of original and the providedtargetParentURI part instead ofsourceParentpart.- Parameters:
sourceProject- the source object project, cannot benullsourceParent- the source object parent, cannot benullsource- the source object, cannot benulltargetProject- the target project to create proxy in, cannot benulltargetParent- the target proxy object parent, cannot benulltargetReference- the target proxy reference, cannot benullcontext- 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 benullprojectFrom- the project to copy resource from, cannot benullprojectTo- the project to copy resource to, cannot benullprojectFileSystemSupportTo- the project filesystem support to copy resource from, cannot benullprojectFileSystemSupportFrom- the project filesystem support to copy resource to, cannot benullowner- the external property owner, cannot benullreference- the external property reference feature, cannot benullexternalProperty- 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 benullfromObject- the object to copy reference feature from, cannot benullfromReference- the reference feature to copy, cannot benulltoProject- the project to create proxy in, cannot benulltoObject- the object to copy reference feature to, cannot benulltoReference- the reference feature to copy, cannot benullcontext- the copy context, cannot benullresolveProxies- whether proxies should be resolved while copyinguseOriginalReferences- whether non-copied references should be used while copying- Returns:
- the result of the copied reference:
EObjectelement or a collection ofEObjectelements, 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 benulltoFile- 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 benullowner- the external property owner, cannot benullreference- the reference to external property, cannot benull- Returns:
- the generated external property FQN, never
null
-