public class EAResourceUtils
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static interface |
EAResourceUtils.AddElementsRunnable
Used by
addElements(AddElementsRunnable) . |
Constructor and Description |
---|
EAResourceUtils() |
Modifier and Type | Method and Description |
---|---|
static void |
addElements(EAResourceUtils.AddElementsRunnable runnable)
Just like
addElements(Map) but the actual adding is delegated to the runnable. |
static java.util.Collection<EObject> |
addElements(java.util.Map<EObject,Setting> elementsToParentAndFeatureMap)
Add multiple elements at once to an EA model.
|
static boolean |
addTaggedValue(EModelElement element,
java.lang.String key,
java.lang.String value,
boolean insertAsFirstElement) |
static Setting |
createSetting(EObject element,
EReference feature)
Create a new setting for the tuple parent and feature that can be used for
addElements(Map) . |
static java.util.List<EAModelError> |
getEAModelErrors(Resource resource)
The
EAResource produces warnings and errors during loading and saving. |
static EObject |
getElementForGuid(Resource resource,
java.lang.String guid)
Assuming that the given
EAResource is initialized with a single IEAContentFactory (e.g. |
static java.lang.String |
getGuidForElement(EObject element)
If the given element is
connected to EA , then this call returns the
EA-specific globally unique identifier (GUID) of it. |
static java.lang.Integer |
getIdForElement(EObject element)
If the given element is
connected to EA , then this call returns the
EA-specific identifier (ID) of it. |
static java.lang.String |
getObjectTypeForElement(EObject element)
If the given element is
connected to EA , then this call returns the
EA-specific type of it, which can either be EA package , element , operation
, attribute , or connector . |
static boolean |
isEAConnectedElement(EObject object)
This call checks whether the given EObject is an element that was provided by an
IEAContentFactory and
has IDs associated that corresponds to a model element in the corresponding EA model. |
static boolean |
isEaFile(IFile file)
Checks whether the given file provides an eap file extension.
|
static boolean |
isEaUri(URI uri)
Checks whether the given uri provides an eap file extension.
|
static boolean |
isLocalEaFile(IFile file)
EA models may either be eap file on the local file system or remote databases such as MSSQL, MySQL or Oracle
databases.
|
static boolean |
isLocalEaResource(Resource resource)
EA models may either be eap file on the local file system or remote databases such as MSSQL, MySQL, or Oracle
databases.
|
static boolean |
isLocalEaUri(URI uri)
EA models may either be eap file on the local file system or remote databases such as MSSQL, MySQL, or Oracle
databases.
|
static boolean |
isRemoteEaFile(IFile file)
EA models may either be eap files on the local file system or remote databases such as MSSQL, MySQL or Oracle
databases.
|
static boolean |
isRemoteEaResource(Resource resource)
EA models may either be eap files on the local file system or remote databases such as MSSQL, MySQL, or Oracle
databases.
|
static boolean |
isRemoteEaUri(URI uri)
EA models may either be eap files on the local file system or remote databases such as MSSQL, MySQL or Oracle
databases.
|
static EAResource |
loadEAResourceSilent(IFile file,
boolean readOnly,
org.eclipse.core.runtime.IProgressMonitor monitor)
This helper is a convenience method for loading an eap-file read-only inside a new resource set without error
reporting.
|
static EAResource |
loadEAResourceSilent(URI uri,
boolean readOnly,
org.eclipse.core.runtime.IProgressMonitor monitor)
This helper method is a convenience method for loading an eap-file read-only inside a new resource set without
error reporting:
|
public static EAResource loadEAResourceSilent(IFile file, boolean readOnly, org.eclipse.core.runtime.IProgressMonitor monitor) throws java.io.FileNotFoundException
URI
and delegates to
#loadEAResourceReadOnly(URI, IProgressMonitor)
.file
- An eap-file.readOnly
- Whether or not to set the read-only
flag.monitor
- An optional progress monitor for resource loading.EAResource
or null
if it could not be loaded.java.io.FileNotFoundException
- In case the file does not exist.java.lang.RuntimeException
- Maybe if loading was interrupted via the progress monitor.EAResourceUtils#loadEAResourceReadOnly(URI, IProgressMonitor)
public static EAResource loadEAResourceSilent(URI uri, boolean readOnly, org.eclipse.core.runtime.IProgressMonitor monitor) throws java.io.FileNotFoundException
final ResourceSetImpl set = new ResourceSetImpl(); set.getLoadOptions().put(EAResource.OPTION_READONLY, readOnly); set.getLoadOptions().put(EAResource.OPTION_REPORT_AS_RESOURCE_MARKERS, false); // disable error reporting set.getLoadOptions().put(EAResource.OPTION_REPORT_TO_ERROR_LOG, false); // disable error reporting return (EAResource) set.getResource(uri, true);
uri
- An URI to an eap-file.readOnly
- Whether or not to set the read-only
flag.monitor
- Optional progress monitor.EAResource
or null
if it could not be loaded.java.io.FileNotFoundException
- In case the URI does not point to an existing file.java.lang.RuntimeException
- Maybe if loading was interrupted via the progress monitor.public static boolean isEAConnectedElement(EObject object)
IEAContentFactory
and
has IDs associated that corresponds to a model element in the corresponding EA model.object
- A model element.public static EObject getElementForGuid(Resource resource, java.lang.String guid)
EAResource
is initialized with a single IEAContentFactory
(e.g. UML
content factory), then the element with the given GUID is searched and returned, if it exists.resource
- An instance of EAResource
(otherwise an IllegalArgumentException
is thrown).guid
- A Guid (must not be null or empty).null
if none could be found.public static java.lang.String getGuidForElement(EObject element)
connected to EA
, then this call returns the
EA-specific globally unique identifier (GUID) of it.element
- A model element that is stored in an EA model.null
otherwise.public static java.lang.Integer getIdForElement(EObject element)
connected to EA
, then this call returns the
EA-specific identifier (ID) of it. This ID is unique within the model element's type which can either be EA
packages, elements, operations, attributes, or connectors (see also getObjectTypeForElement(EObject)
).element
- A model element that is stored in an EA model.null
otherwise.public static java.lang.String getObjectTypeForElement(EObject element)
connected to EA
, then this call returns the
EA-specific type of it, which can either be EA package
, element
, operation
, attribute
, or connector
.
Please note that parameter do not have a specific type, so the return value for parameters is
null
!
element
- A model element that is stored in an EA model.null
otherwise.public static boolean isLocalEaFile(IFile file)
file
- An EA file.true
if the file is a local eap file; false
if it is not an eap file or if it
is a file for a remote database.public static boolean isEaUri(URI uri)
uri
- The uri to test.true
if the file extension of the given uri indicates an eap file.public static boolean isEaFile(IFile file)
file
- The file to test.true
if the file extension of the given uri indicates an eap file.public static boolean isLocalEaUri(URI uri)
uri
- A uri.true
if the file name of this uri is a local eap file; false
if it is not an
eap file or if it is a file for a remote database.public static boolean isLocalEaResource(Resource resource)
resource
- An EA resource.true
if the resource is loaded for a local eap file; false
if it is not an
EAResource
or if the EA model is loaded from a remote database.public static boolean isRemoteEaResource(Resource resource)
resource
- An EA resource.true
if the resource is loaded from a remote database; false
if it is not an
EAResource
or if the EA model is a local eap file.public static boolean isRemoteEaFile(IFile file)
file
- An EA file.true
if the file name indicates a remote database; false
if it is not an eap
file or if it is a local eap file.public static boolean isRemoteEaUri(URI uri)
uri
- An URI.true
if the file name of the given uri indicates a remote database; false
if it
is not an eap file or if it is a local eap file.public static java.util.List<EAModelError> getEAModelErrors(Resource resource)
EAResource
produces warnings and errors during loading and saving. This is a convenience method to
collect them all at once from the EAResource#getErrors()
and EAResource#getWarnings()
lists.resource
- A resource.warnings and errors
produced by the EAResource
during loading and/or
saving. All other errors or warnings are NOT included (e.g. if this method is called on some other
resource than EAResource
).public static java.util.Collection<EObject> addElements(java.util.Map<EObject,Setting> elementsToParentAndFeatureMap)
Due to technical restrictions, it is not possible to add multiple model fragments to the EA model that contain cross reference cycles. If there are, for instance, two UML classes A and B that contain the following properties:
A
contains property b: B
B
contains property a: A
addAll
is used, then the YAKINDU EA-Bridge
knows all elements that should be added and cross references are properly set. However, if the elements to be
added do not share the same parent and feature, it is not possible to add elements with cross references with
available API that is provided by EMF/UML.
This call can thus be used to add multiple elements with cross references between each other and with different
parents. The elements must be provided in a map whose values must be setting
which specify the respective parent and containing feature.
If some of the elements cannot be stored properly, the usual error handling as
resource markers
, to the
error log
, into a
custom collection
, and/or as
thrown exception
is performed.
EAResource
, the elements are simply added.elementsToAdd
- A map of all elements to be added to the model and which may contain cross references between each
other; createSetting(EObject, EReference)
can be used to create the settings.public static void addElements(EAResourceUtils.AddElementsRunnable runnable)
addElements(Map)
but the actual adding is delegated to the runnable.public static Setting createSetting(EObject element, EReference feature)
addElements(Map)
.element
- An element.feature
- A feature of the element.public static boolean addTaggedValue(EModelElement element, java.lang.String key, java.lang.String value, boolean insertAsFirstElement)
Copyright (c) 2015 itemis AG, and others. All rights reserved.