Search in sources :

Example 11 with XMLResource

use of org.eclipse.emf.ecore.xmi.XMLResource in project jbpm by kiegroup.

the class DroolsResourceFactoryImpl method createResource.

/**
 * Creates an instance of the resource.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public Resource createResource(URI uri) {
    XMLResource result = new DroolsResourceImpl(uri);
    result.getDefaultSaveOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
    result.getDefaultLoadOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
    result.getDefaultSaveOptions().put(XMLResource.OPTION_SCHEMA_LOCATION, Boolean.TRUE);
    result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE);
    result.getDefaultSaveOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE);
    result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_LEXICAL_HANDLER, Boolean.TRUE);
    return result;
}
Also used : XMLResource(org.eclipse.emf.ecore.xmi.XMLResource)

Example 12 with XMLResource

use of org.eclipse.emf.ecore.xmi.XMLResource in project jbpm by kiegroup.

the class ColorResourceFactoryImpl method createResource.

/**
 * Creates an instance of the resource.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public Resource createResource(URI uri) {
    XMLResource result = new ColorResourceImpl(uri);
    result.getDefaultSaveOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
    result.getDefaultLoadOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
    result.getDefaultSaveOptions().put(XMLResource.OPTION_SCHEMA_LOCATION, Boolean.TRUE);
    result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE);
    result.getDefaultSaveOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE);
    result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_LEXICAL_HANDLER, Boolean.TRUE);
    return result;
}
Also used : XMLResource(org.eclipse.emf.ecore.xmi.XMLResource)

Example 13 with XMLResource

use of org.eclipse.emf.ecore.xmi.XMLResource in project jbpm by kiegroup.

the class BpsimResourceFactoryImpl method createResource.

/**
 * Creates an instance of the resource.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public Resource createResource(URI uri) {
    XMLResource result = new BpsimResourceImpl(uri);
    result.getDefaultSaveOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
    result.getDefaultLoadOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
    result.getDefaultSaveOptions().put(XMLResource.OPTION_SCHEMA_LOCATION, Boolean.TRUE);
    result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE);
    result.getDefaultSaveOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE);
    result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_LEXICAL_HANDLER, Boolean.TRUE);
    return result;
}
Also used : XMLResource(org.eclipse.emf.ecore.xmi.XMLResource)

Example 14 with XMLResource

use of org.eclipse.emf.ecore.xmi.XMLResource in project InformationSystem by ObeoNetwork.

the class SoaMigrationHelper method removeDtoRegistry.

private void removeDtoRegistry(Namespace dtoRegistry) {
    System system = (System) dtoRegistry.eContainer();
    if (!dtoRegistry.getOwnedNamespaces().isEmpty()) {
        // Store XMI IDs
        Map<EObject, String> eObjectToIds = new HashMap<EObject, String>();
        TreeIterator<EObject> eAllContents = dtoRegistry.eAllContents();
        while (eAllContents.hasNext()) {
            EObject child = eAllContents.next();
            String xmiId = child.eResource().getURIFragment(child);
            eObjectToIds.put(child, xmiId);
        }
        // Change parent of children
        Collection<Namespace> children = new ArrayList<Namespace>(dtoRegistry.getOwnedNamespaces());
        for (Namespace child : children) {
            system.getOwnedNamespaces().add(child);
        }
        // Restore XMI IDs
        for (Entry<EObject, String> eObjectToIdEntry : eObjectToIds.entrySet()) {
            EObject object = eObjectToIdEntry.getKey();
            String id = eObjectToIdEntry.getValue();
            ((XMLResource) object.eResource()).setID(object, id);
        }
    }
    // Delete old DTO registry
    EcoreUtil.delete(dtoRegistry, false);
}
Also used : HashMap(java.util.HashMap) EObject(org.eclipse.emf.ecore.EObject) ArrayList(java.util.ArrayList) System(org.obeonetwork.dsl.soa.System) Namespace(org.obeonetwork.dsl.environment.Namespace) XMLResource(org.eclipse.emf.ecore.xmi.XMLResource)

Example 15 with XMLResource

use of org.eclipse.emf.ecore.xmi.XMLResource in project InformationSystem by ObeoNetwork.

the class AbstractDatabaseCompareTest method serialize.

protected String serialize(EObject root) throws IOException {
    if (root == null)
        return "";
    // Copies the root to avoid modifying it
    final EObject copyRoot = EcoreUtil.copy(root);
    // $NON-NLS-1$
    attachResource(URI.createFileURI("resource.xml"), copyRoot);
    final StringWriter writer = new StringWriter();
    final Map<String, String> options = new HashMap<String, String>();
    options.put(XMLResource.OPTION_ENCODING, System.getProperty("file.encoding"));
    // Should not throw ClassCast since uri calls for an xml resource
    ((XMLResource) copyRoot.eResource()).save(writer, options);
    final String result = writer.toString();
    writer.flush();
    return result;
}
Also used : StringWriter(java.io.StringWriter) HashMap(java.util.HashMap) EObject(org.eclipse.emf.ecore.EObject) XMLResource(org.eclipse.emf.ecore.xmi.XMLResource)

Aggregations

XMLResource (org.eclipse.emf.ecore.xmi.XMLResource)38 HashMap (java.util.HashMap)12 ByteArrayInputStream (java.io.ByteArrayInputStream)8 StringWriter (java.io.StringWriter)8 InputStream (java.io.InputStream)6 EObject (org.eclipse.emf.ecore.EObject)5 DocumentRoot (org.jboss.drools.DocumentRoot)5 DocumentRoot (org.eclipse.bpmn2.DocumentRoot)3 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)3 ResourceSetImpl (org.eclipse.emf.ecore.resource.impl.ResourceSetImpl)3 IOException (java.io.IOException)2 Bpmn2ResourceFactoryImpl (org.eclipse.bpmn2.util.Bpmn2ResourceFactoryImpl)2 URI (org.eclipse.emf.common.util.URI)2 Resource (org.eclipse.emf.ecore.resource.Resource)2 DroolsResourceFactoryImpl (org.jboss.drools.util.DroolsResourceFactoryImpl)2 BPSimDataType (bpsim.BPSimDataType)1 DocumentRoot (bpsim.DocumentRoot)1 ElementParameters (bpsim.ElementParameters)1 Parameter (bpsim.Parameter)1 Scenario (bpsim.Scenario)1