Java 类org.eclipse.emf.ecore.EPackage.Registry 实例源码

项目:org.lovian.eaxmireader    文件:InitResourceSet.java   
/**
 * Register all the SysML default packages
 * 
 * @param packageRegistry
 */
private void registSysMLPackages(Registry packageRegistry) {
    // Register all default SYSML packages
    packageRegistry.put(SysmlPackage.eNS_URI, SysmlPackage.eINSTANCE);
    packageRegistry.put(ActivitiesPackage.eNS_URI, ActivitiesPackage.eINSTANCE);
    packageRegistry.put(AllocationsPackage.eNS_URI, AllocationsPackage.eINSTANCE);
    packageRegistry.put(BlocksPackage.eNS_URI, BlocksPackage.eINSTANCE);
    packageRegistry.put(ConstraintsPackage.eNS_URI, ConstraintsPackage.eINSTANCE);
    packageRegistry.put(InteractionsPackage.eNS_URI, InteractionsPackage.eINSTANCE);
    packageRegistry.put(ModelelementsPackage.eNS_URI, ModelelementsPackage.eINSTANCE);
    packageRegistry.put(PortandflowsPackage.eNS_URI, PortandflowsPackage.eINSTANCE);
    packageRegistry.put(RequirementsPackage.eNS_URI, RequirementsPackage.eINSTANCE);
    packageRegistry.put(StatemachinesPackage.eNS_URI, StatemachinesPackage.eINSTANCE);
    packageRegistry.put(UsecasesPackage.eNS_URI, UsecasesPackage.eINSTANCE);
    packageRegistry.put(UsecasesPackage.eNS_URI, UsecasesPackage.eINSTANCE);
}
项目:xtext-core    文件:EcoreUtil2Test.java   
@Test public void testExternalFormOfEReference() throws Exception {
    Registry registry = EPackage.Registry.INSTANCE;
    Set<String> uris = Sets.newHashSet(registry.keySet());
    for (String string : uris) {
        EPackage ePackage = registry.getEPackage(string);
        TreeIterator<Object> iterator = EcoreUtil.getAllProperContents(ePackage, true);
        while (iterator.hasNext()) {
            Object next = iterator.next();
            if (next instanceof EReference) {
                EReference ref = (EReference) next;
                String externalForm = EcoreUtil2.toExternalForm(ref);
                assertEquals(ref.toString() + " - " + externalForm, ref, EcoreUtil2.getEReferenceFromExternalForm(registry,externalForm));
            }
        }
    }
}
项目:xtext-core    文件:EcoreUtil2Test.java   
/**
 * This test assumes that an EPackage with indexed references is no longer available.
 */
@Test public void testExternalFormOfEReferenceNoNPE() throws Exception {
    EReference reference = EcorePackage.Literals.EATTRIBUTE__EATTRIBUTE_TYPE;
    URI uri = EcoreUtil.getURI(reference);
    String externalForm = uri.toString();
    EReference foundReference = EcoreUtil2.getEReferenceFromExternalForm(EPackage.Registry.INSTANCE, externalForm);
    assertSame(reference, foundReference);
    String brokenExternalFrom = makeInvalid(externalForm);
    assertNull(EcoreUtil2.getEReferenceFromExternalForm(EPackage.Registry.INSTANCE, brokenExternalFrom));
    String shortExternalForm = EcoreUtil2.toExternalForm(reference);
    foundReference = EcoreUtil2.getEReferenceFromExternalForm(EPackage.Registry.INSTANCE, shortExternalForm);
    assertSame(reference, foundReference);
    String brokenShortExternalFrom = makeInvalid(shortExternalForm);
    assertNull(EcoreUtil2.getEReferenceFromExternalForm(EPackage.Registry.INSTANCE, brokenShortExternalFrom));
    brokenShortExternalFrom = shortExternalForm.replace('A', 'a');
    assertNull(EcoreUtil2.getEReferenceFromExternalForm(EPackage.Registry.INSTANCE, brokenShortExternalFrom));
}
项目:mondo-integration    文件:HawkResourceImpl.java   
private void handle(final HawkModelElementAdditionEvent ev) {
    final Registry registry = getResourceSet().getPackageRegistry();
    final EClass eClass = HawkResourceImpl.getEClass(ev.metamodelURI, ev.typeName, registry);
    final EObject existing = nodeIdToEObjectMap.get(ev.id);
    if (existing == null) {
        final EObject eob = createInstance(eClass);
        nodeIdToEObjectMap.put(ev.id, eob);
        synchronized(classToEObjectsMap) {
            final EList<EObject> instances = classToEObjectsMap.get(eClass);
            if (instances != null) {
                instances.add(eob);
            }
        }
        addToResource(ev.vcsItem.repoURL, ev.vcsItem.path, eob);
        LOGGER.debug("Added a new {} with ID {}", eob.eClass().getName(), ev.id);
        instanceInserted(eob, eob.eClass());
    } else {
        LOGGER.warn("We already have a {} with ID {}: cannot create a {} there", existing.eClass().getName(), ev.id, eClass.getName());
    }
}
项目:mondo-integration    文件:HawkResourceImpl.java   
private static EClass getEClass(final String metamodelUri, final String typeName,
        final Registry packageRegistry) {
    final EPackage pkg = packageRegistry.getEPackage(metamodelUri);
    if (pkg == null) {
        throw new NoSuchElementException(String.format(
                "Could not find EPackage with URI '%s' in the registry",
                metamodelUri));
    }

    final EClassifier eClassifier = pkg.getEClassifier(typeName);
    if (!(eClassifier instanceof EClass)) {
        throw new NoSuchElementException(String.format(
                "Received an element of type '%s', which is not an EClass",
                eClassifier));
    }
    final EClass eClass = (EClass) eClassifier;
    return eClass;
}
项目:mondo-hawk    文件:HawkResourceImpl.java   
private void handle(final HawkModelElementAdditionEvent ev) {
    final Registry registry = getResourceSet().getPackageRegistry();
    final EClass eClass = HawkResourceImpl.getEClass(ev.metamodelURI, ev.typeName, registry);
    final EObject existing = nodeIdToEObjectMap.get(ev.id);
    if (existing == null) {
        final EObject eob = createInstance(eClass);
        nodeIdToEObjectMap.put(ev.id, eob);
        synchronized(classToEObjectsMap) {
            final EList<EObject> instances = classToEObjectsMap.get(eClass);
            if (instances != null) {
                instances.add(eob);
            }
        }
        addToResource(ev.vcsItem.repoURL, ev.vcsItem.path, eob);
        LOGGER.debug("Added a new {} with ID {}", eob.eClass().getName(), ev.id);
        instanceInserted(eob, eob.eClass());
    } else {
        LOGGER.warn("We already have a {} with ID {}: cannot create a {} there", existing.eClass().getName(), ev.id, eClass.getName());
    }
}
项目:mondo-hawk    文件:HawkResourceImpl.java   
private static EClass getEClass(final String metamodelUri, final String typeName,
        final Registry packageRegistry) {
    final EPackage pkg = packageRegistry.getEPackage(metamodelUri);
    if (pkg == null) {
        throw new NoSuchElementException(String.format(
                "Could not find EPackage with URI '%s' in the registry",
                metamodelUri));
    }

    final EClassifier eClassifier = pkg.getEClassifier(typeName);
    if (!(eClassifier instanceof EClass)) {
        throw new NoSuchElementException(String.format(
                "Received an element of type '%s', which is not an EClass",
                eClassifier));
    }
    final EClass eClass = (EClass) eClassifier;
    return eClass;
}
项目:mondo-hawk    文件:LocalHawkResourceImpl.java   
private static EClass getEClass(final String metamodelUri, final String typeName,
        final Registry packageRegistry) {
    final EPackage pkg = packageRegistry.getEPackage(metamodelUri);
    if (pkg == null) {
        throw new NoSuchElementException(String.format(
                "Could not find EPackage with URI '%s' in the registry %s",
                metamodelUri, packageRegistry));
    }

    final EClassifier eClassifier = pkg.getEClassifier(typeName);
    if (!(eClassifier instanceof EClass)) {
        throw new NoSuchElementException(String.format(
                "Received an element of type '%s', which is not an EClass",
                eClassifier));
    }
    final EClass eClass = (EClass) eClassifier;
    return eClass;
}
项目:mondo-collab-framework    文件:HawkResourceImpl.java   
private void handle(final HawkModelElementAdditionEvent ev) {
    final Registry registry = getResourceSet().getPackageRegistry();
    final EClass eClass = HawkResourceImpl.getEClass(ev.metamodelURI, ev.typeName, registry);
    final EObject existing = nodeIdToEObjectMap.get(ev.id);
    if (existing == null) {
        final EObject eob = createInstance(eClass);
        nodeIdToEObjectMap.put(ev.id, eob);
        synchronized(classToEObjectsMap) {
            final EList<EObject> instances = classToEObjectsMap.get(eClass);
            if (instances != null) {
                instances.add(eob);
            }
        }
        addToResource(ev.vcsItem.repoURL, ev.vcsItem.path, eob);
        LOGGER.debug("Added a new {} with ID {}", eob.eClass().getName(), ev.id);
        instanceInserted(eob, eob.eClass());
    } else {
        LOGGER.warn("We already have a {} with ID {}: cannot create a {} there", existing.eClass().getName(), ev.id, eClass.getName());
    }
}
项目:mondo-collab-framework    文件:HawkResourceImpl.java   
private static EClass getEClass(final String metamodelUri, final String typeName,
        final Registry packageRegistry) {
    final EPackage pkg = packageRegistry.getEPackage(metamodelUri);
    if (pkg == null) {
        throw new NoSuchElementException(String.format(
                "Could not find EPackage with URI '%s' in the registry",
                metamodelUri));
    }

    final EClassifier eClassifier = pkg.getEClassifier(typeName);
    if (!(eClassifier instanceof EClass)) {
        throw new NoSuchElementException(String.format(
                "Received an element of type '%s', which is not an EClass",
                eClassifier));
    }
    final EClass eClass = (EClass) eClassifier;
    return eClass;
}
项目:NeoEMF    文件:AbstractInputTest.java   
/**
 * Registers a EPackage in {@link Registry} according to its {@code prefix} and {@code uri}, from an Ecore file.
 * <p>
 * The targeted Ecore file must be present in {@code /resources/ecore}.
 */
protected static void registerEPackageFromEcore(String prefix, String uri) {
    File file = getResourceFile(ECORE_PATH.replaceAll("\\{name\\}", prefix));

    EPackage ePackage = null;

    Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(ECORE, new EcoreResourceFactoryImpl());

    ResourceSet rs = new ResourceSetImpl();

    final ExtendedMetaData extendedMetaData = new BasicExtendedMetaData(rs.getPackageRegistry());
    rs.getLoadOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, extendedMetaData);

    Resource r = rs.getResource(URI.createFileURI(file.toString()), true);
    EObject eObject = r.getContents().get(0);
    if (eObject instanceof EPackage) {
        ePackage = (EPackage) eObject;
        rs.getPackageRegistry().put(ePackage.getNsURI(), ePackage);
    }

    assertThat(ePackage).isNotNull(); // "EPackage does not exist"

    Registry.INSTANCE.put(uri, ePackage);
}
项目:emfstore-rest    文件:EPackageRegistryHelper.java   
/**
 * Gets all available EPackages from the EPackageRegistry.
 * 
 * @param filterKnown weather known packages should be filtered or not.
 * @return the available packages
 * 
 */
public static Set<EPackage> getAvailablePackages(boolean filterKnown) {
    Registry registry = EPackage.Registry.INSTANCE;
    HashSet<Entry<String, Object>> entries = new LinkedHashSet<Entry<String, Object>>(registry.entrySet());

    Set<EPackage> packages = new LinkedHashSet<EPackage>();
    for (Entry<String, Object> entry : entries) {
        if (!filterKnown || !isKnownPackage(entry.getKey())) {
            try {
                EPackage ePackage = EPackage.Registry.INSTANCE.getEPackage(entry.getKey());
                packages.add(ePackage);
                // BEGIN SUPRESS CATCH EXCEPTION
            } catch (RuntimeException e) {
                // END SUPRESS CATCH EXCEPTION
                WorkspaceUtil.logWarning("Failed to load EPackage", e);
            }
        }
    }
    return packages;
}
项目:emfstore-rest    文件:ModelMutatorUtil.java   
/**
 * Iterates over all registered EPackages in order to retrieve all available
 * EClasses, excluding abstract classes and interfaces, and returns them as
 * a Set.
 * 
 * @return a set of all EClasses that are contained in registered EPackages
 * @see Registry
 */
public List<EClass> getAllEClasses() {
    if (allEClasses == null) {
        allEClasses = new ArrayList<EClass>();
        Registry registry = EPackage.Registry.INSTANCE;
        // for all registered EPackages
        for (Entry<String, Object> entry : new LinkedHashSet<Entry<String, Object>>(registry.entrySet())) {
            EPackage ePackage = registry.getEPackage(entry.getKey());
            for (EClass eClass : getAllEClasses(ePackage)) {
                // no abstracts or interfaces
                if (canHaveInstance(eClass)) {
                    allEClasses.add(eClass);
                }
            }
        }
    }
    return allEClasses;
}
项目:emfstore-rest    文件:CommonUtil.java   
/**
 * Retrieve all EClasses from the ECore package registry.
 * 
 * @return a set of EClasses
 */
public static Set<EClass> getAllModelElementEClasses() {

    if (registryEClasses != null) {
        return new LinkedHashSet<EClass>(registryEClasses);
    }

    final Set<EClass> result = new LinkedHashSet<EClass>();
    final Registry registry = EPackage.Registry.INSTANCE;

    for (Entry<String, Object> entry : new LinkedHashSet<Entry<String, Object>>(registry.entrySet())) {
        try {
            final EPackage ePackage = EPackage.Registry.INSTANCE.getEPackage(entry.getKey());
            result.addAll(getAllModelElementEClasses(ePackage));
        }
        // BEGIN SUPRESS CATCH EXCEPTION
        catch (RuntimeException exception) {
            Activator.getDefault().logException("Failed to load model package " + entry.getKey(), exception);
            // END SUPRESS CATCH EXCEPTION
        }

    }

    registryEClasses = result;
    return result;
}
项目:k3    文件:ModelGeneratorUtil.java   
/**
 * Returns all EPackages on the root level that are currently registered in
 * the registry.
 * 
 * @return a Set of all root EPackages
 * @see Registry
 */
public  Set<EPackage> getAllRootEPackages() {
    // were the root packages computed before?
    if (rootModelPackages != null) {
        return rootModelPackages;
    }
    rootModelPackages = new LinkedHashSet<EPackage>();
    Registry registry = EPackage.Registry.INSTANCE;

    for (Entry<String, Object> entry : registry.entrySet()) {
        EPackage ePackage = registry.getEPackage(entry.getKey());
        // is the current EPackage a root package?
        if (ePackage.getESuperPackage() == null) {
            rootModelPackages.add(ePackage);
        }
    }
    return rootModelPackages;
}
项目:k3    文件:ModelGeneratorUtil.java   
/**
 * Iterates over all registered EPackages in order to retrieve all available
 * EClasses, excluding abstract classes and interfaces, and returns them as
 * a Set.
 * 
 * @return a set of all EClasses that are contained in registered EPackages
 * @see Registry
 */
public  List<EClass> getAllEClasses() {
    // were all EClasses computed before?
    if (allEClasses != null) {
        return allEClasses;
    }
    allEClasses = new LinkedList<EClass>();
    Registry registry = EPackage.Registry.INSTANCE;
    // for all registered EPackages
    for (Entry<String, Object> entry : registry.entrySet()) {
        EPackage ePackage = registry.getEPackage(entry.getKey());
        for (EClass eClass : getAllEClasses(ePackage)) {
            // no abstracts or interfaces
            if (canHaveInstance(eClass)) {
                allEClasses.add(eClass);
            }
        }
    }
    return allEClasses;
}
项目:org.lovian.eaxmireader    文件:InitResourceSet.java   
/**
 * Initialize the UML resourceSet and register all the packages by default
 * 
 * @return resourceSet
 * @throws IOException
 */
public ResourceSet initResourceSet() throws IOException {
    String method = "InitResourceSet_initResourceSet(): ";
    long startTime = System.currentTimeMillis();
    MyLog.info(method + "start");

    ResourceSet resourceSet = new ResourceSetImpl();
    Registry packageRegistry = resourceSet.getPackageRegistry();

    // Read the namespace configuration file
    String namespaceConfigPath = FileLocator
            .toFileURL(Activator.getDefault().getBundle().getEntry(NAMESPACE_CONFIG_FILE_PAHT)).getPath();
    File namespaceConfigFile = new File(namespaceConfigPath);

    Properties properties = new Properties();
    properties.load(new FileInputStream(namespaceConfigFile));

    // Load and register the self-definition namespaces
    for (String key : properties.stringPropertyNames()) {
        String value = properties.getProperty(key);
        packageRegistry.put(value, UMLPackage.eINSTANCE);
    }

    registSysMLPackages(packageRegistry);

    // Add the load option
    resourceSet.getLoadOptions().put(XMIResource.OPTION_RECORD_UNKNOWN_FEATURE, Boolean.TRUE);

    // Define the extension to factory map
    Map<String, Object> extensionToFactoryMap = resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap();
    UMLResourceFactoryImpl umlResourceFactory = new UMLResourceFactoryImpl();
    extensionToFactoryMap.put(XMI2UMLResource.FILE_EXTENSION, umlResourceFactory);

    MyLog.info(method + "end with " + (System.currentTimeMillis() - startTime) + " millisecond");
    MyLog.info();
    return resourceSet;
}
项目:xtext-core    文件:EcoreUtil2Test.java   
@Test public void testClone() throws Exception {
    Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION,
            new XMIResourceFactoryImpl());
    EPackage.Registry.INSTANCE.put(EcorePackage.eINSTANCE.getNsURI(), EcorePackage.eINSTANCE);

    ResourceSetImpl rs = new ResourceSetImpl();
    Resource r1 = rs.createResource(URI.createURI("foo.xmi"), ContentHandler.UNSPECIFIED_CONTENT_TYPE);
    Resource r2 = rs.createResource(URI.createURI("bar.xmi"), ContentHandler.UNSPECIFIED_CONTENT_TYPE);
    EClass a = EcoreFactory.eINSTANCE.createEClass();
    a.setName("a");
    EClass b = EcoreFactory.eINSTANCE.createEClass();
    r1.getContents().add(a);
    b.setName("b");
    b.getESuperTypes().add(a);
    r2.getContents().add(b);

    ResourceSetImpl clone = EcoreUtil2.clone(new ResourceSetImpl(), rs);
    EList<Resource> list = clone.getResources();

    Resource resA = list.get(0);
    assertEquals(URI.createURI("foo.xmi"),resA.getURI());
    assertNotSame(resA, r1);

    Resource resB = list.get(1);
    assertEquals(URI.createURI("bar.xmi"),resB.getURI());
    assertNotSame(resB, r2);

    EClass a1 = (EClass)resA.getContents().get(0);
    EClass b1 = (EClass)resB.getContents().get(0);
    assertEquals("a", a1.getName());
    assertNotSame(a, a1);
    assertEquals("b", b1.getName());
    assertNotSame(b, b1);
    assertSame(b1.getESuperTypes().get(0),a1);
    assertSame(b.getESuperTypes().get(0),a);
}
项目:mondo-integration    文件:HawkResourceImpl.java   
private EObject createEObject(final ModelElement me) throws IOException {
    final Registry registry = getResourceSet().getPackageRegistry();
    final EClass eClass = getEClass(me.metamodelUri, me.typeName, registry);
    final EObject obj = createInstance(eClass);

    if (me.isSetId()) {
        nodeIdToEObjectMap.put(me.id, obj);

        synchronized(classToEObjectsMap) {
            final EList<EObject> instances = classToEObjectsMap.get(eClass);
            if (instances != null) {
                instances.add(obj);
            }
        }
    }

    if (me.isSetAttributes()) {
        final EFactory factory = registry.getEFactory(eClass.getEPackage().getNsURI());
        for (final AttributeSlot s : me.attributes) {
            SlotDecodingUtils.setFromSlot(factory, eClass, obj, s);
        }
    } else if (!descriptor.getLoadingMode().isGreedyAttributes()) {
        getLazyResolver().putLazyAttributes(me.id, obj);
    }

    return obj;
}
项目:mondo-integration    文件:HawkResourceImpl.java   
private void fillInReferences(final List<ModelElement> elems, final TreeLoadingState state) throws IOException {
    final Registry packageRegistry = getResourceSet().getPackageRegistry();

    for (final ModelElement me : elems) {
        final EObject sourceObj = state.meToEObject.remove(me);
        fillInReferences(packageRegistry, me, sourceObj, state);
    }
}
项目:mondo-hawk    文件:HawkResourceImpl.java   
private EObject createEObject(final ModelElement me) throws IOException {
    final Registry registry = getResourceSet().getPackageRegistry();
    final EClass eClass = getEClass(me.metamodelUri, me.typeName, registry);
    final EObject obj = createInstance(eClass);

    if (me.isSetId()) {
        nodeIdToEObjectMap.put(me.id, obj);

        synchronized(classToEObjectsMap) {
            final EList<EObject> instances = classToEObjectsMap.get(eClass);
            if (instances != null) {
                instances.add(obj);
            }
        }
    }

    if (me.isSetAttributes()) {
        final EFactory factory = registry.getEFactory(eClass.getEPackage().getNsURI());
        for (final AttributeSlot s : me.attributes) {
            SlotDecodingUtils.setFromSlot(factory, eClass, obj, s);
        }
    } else if (!descriptor.getLoadingMode().isGreedyAttributes()) {
        getLazyResolver().putLazyAttributes(me.id, obj);
    }

    return obj;
}
项目:mondo-hawk    文件:HawkResourceImpl.java   
private void fillInReferences(final List<ModelElement> elems, final TreeLoadingState state) throws IOException {
    final Registry packageRegistry = getResourceSet().getPackageRegistry();

    for (final ModelElement me : elems) {
        final EObject sourceObj = state.meToEObject.remove(me);
        fillInReferences(packageRegistry, me, sourceObj, state);
    }
}
项目:mondo-hawk    文件:LocalHawkResourceUpdater.java   
@Override
public void modelElementAddition(VcsCommitItem s, IHawkObject element, IGraphNode elementNode, boolean isTransient) {
    // new model elements are assumed to be roots unless proven otherwise
    if (isTransient) return;

    final IHawkClassifier type = element.getType();
    final Registry packageRegistry = resource.getResourceSet().getPackageRegistry();
    final EPackage ePackage = packageRegistry.getEPackage(type.getPackageNSURI());
    final EClass eClass = (EClass)ePackage.getEClassifier(type.getName());
    addedRootNodes.put(elementNode, eClass);
}
项目:mondo-hawk    文件:BPMNMetaModelResourceFactory.java   
public BPMNMetaModelResourceFactory() {
    if (EPackage.Registry.INSTANCE.getEPackage(EcorePackage.eNS_URI) == null) {
        EPackage.Registry.INSTANCE.put(EcorePackage.eNS_URI,
                EcorePackage.eINSTANCE);
    }

    resourceSet = new ResourceSetImpl();
    resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap()
            .put("ecore", new EcoreResourceFactoryImpl());
    resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap()
            .put("*", new XMIResourceFactoryImpl());

}
项目:mondo-hawk    文件:BPMNMetaModelResourceFactory.java   
private LinkedList<String> checkRegistry() {

        Registry globalRegistry = EPackage.Registry.INSTANCE;

        LinkedList<String> missingPackages = new LinkedList<>();

        if (!globalRegistry
                .containsKey("http://www.eclipse.org/emf/2003/XMLType"))
            missingPackages.add("http://www.eclipse.org/emf/2003/XMLType");
        if (!globalRegistry
                .containsKey("http://www.omg.org/spec/BPMN/20100524/MODEL-XMI"))
            missingPackages
                    .add("http://www.omg.org/spec/BPMN/20100524/MODEL-XMI");
        if (!globalRegistry
                .containsKey("http://www.omg.org/spec/DD/20100524/DC-XMI"))
            missingPackages.add("http://www.omg.org/spec/DD/20100524/DC-XMI");
        if (!globalRegistry
                .containsKey("http://www.eclipse.org/emf/2002/Ecore"))
            missingPackages.add("http://www.eclipse.org/emf/2002/Ecore");
        if (!globalRegistry
                .containsKey("http://www.omg.org/spec/BPMN/20100524/DI-XMI"))
            missingPackages.add("http://www.omg.org/spec/BPMN/20100524/DI-XMI");
        if (!globalRegistry
                .containsKey("http://www.omg.org/spec/DD/20100524/DI-XMI"))
            missingPackages.add("http://www.omg.org/spec/DD/20100524/DI-XMI");

        return missingPackages;
    }
项目:mondo-collab-framework    文件:HawkResourceImpl.java   
private EObject createEObject(final ModelElement me) throws IOException {
    final Registry registry = getResourceSet().getPackageRegistry();
    final EClass eClass = getEClass(me.metamodelUri, me.typeName, registry);
    final EObject obj = createInstance(eClass);

    if (me.isSetId()) {
        nodeIdToEObjectMap.put(me.id, obj);

        synchronized(classToEObjectsMap) {
            final EList<EObject> instances = classToEObjectsMap.get(eClass);
            if (instances != null) {
                instances.add(obj);
            }
        }
    }

    if (me.isSetAttributes()) {
        final EFactory factory = registry.getEFactory(eClass.getEPackage().getNsURI());
        for (final AttributeSlot s : me.attributes) {
            SlotDecodingUtils.setFromSlot(factory, eClass, obj, s);
        }
    } else if (!descriptor.getLoadingMode().isGreedyAttributes()) {
        getLazyResolver().putLazyAttributes(me.id, obj);
    }

    return obj;
}
项目:mondo-collab-framework    文件:HawkResourceImpl.java   
private void fillInReferences(final List<ModelElement> elems, final TreeLoadingState state) throws IOException {
    final Registry packageRegistry = getResourceSet().getPackageRegistry();

    for (final ModelElement me : elems) {
        final EObject sourceObj = state.meToEObject.remove(me);
        fillInReferences(packageRegistry, me, sourceObj, state);
    }
}
项目:NeoEMF    文件:DirectWriteHBaseStore.java   
/**
 * Compute the {@link EClass} associated to the model element with the provided {@link Id}.
 *
 * @param id the {@link Id} of the model element to compute the {@link EClass} from
 *
 * @return an {@link EClass} representing the metaclass of the element
 */
private EClass resolveInstanceOf(Id id) {
    try {
        Result result = table.get(new Get(Bytes.toBytes(id.toString())));
        String nsURI = Bytes.toString(result.getValue(TYPE_FAMILY, METAMODEL_QUALIFIER));
        String className = Bytes.toString(result.getValue(TYPE_FAMILY, ECLASS_QUALIFIER));
        if (nonNull(nsURI) && nonNull(className)) {
            return (EClass) Registry.INSTANCE.getEPackage(nsURI).getEClassifier(className);
        }
    }
    catch (IOException e) {
        NeoLogger.error("Unable to get instance of information for {0}", id);
    }
    return null;
}
项目:eclectic    文件:Util.java   
public static void register(EPackage... pkgs) {
    for(int i = 0; i < pkgs.length; i++) {
        if (!EPackage.Registry.INSTANCE.containsKey( pkgs[i].getNsURI() )) {
            EPackage.Registry.INSTANCE.put(pkgs[i].getNsURI(), pkgs[i]);
        }
    }       

}
项目:eclectic    文件:Util.java   
public static void register(Registry registry, EPackage... pkgs) {
    for(int i = 0; i < pkgs.length; i++) {
        if (! registry.containsKey( pkgs[i].getNsURI() )) {
            registry.put(pkgs[i].getNsURI(), pkgs[i]);
        }
    }       
}
项目:emfviews    文件:ResourceSelectionBox.java   
@Override
protected boolean processResource(Resource resource) {
  ResourceSet resourceSet = domain.getResourceSet();
  if (!resourceSet.getResources().contains(resource)) {
    Registry packageRegistry = resourceSet.getPackageRegistry();
    for (EPackage ePackage : getAllPackages(resource)) {
      packageRegistry.put(ePackage.getNsURI(), ePackage);
      registeredPackages.add(ePackage);
    }
  }
  return true;
}
项目:xtext-core    文件:LazyLinker.java   
public Registry getRegistry() {
    return registry;
}
项目:xtext-core    文件:LazyLinker.java   
public void setRegistry(Registry registry) {
    this.registry = registry;
}
项目:mondo-hawk    文件:LazyEObjectFactory.java   
public LazyEObjectFactory(Registry registry, MethodInterceptor interceptor) {
    this.packageRegistry = registry;
    this.methodInterceptor = interceptor;
}
项目:mondo-hawk    文件:BPMNMetaModelResourceFactory.java   
@Override
public HashSet<IHawkMetaModelResource> getStaticMetamodels() {

    HashSet<IHawkMetaModelResource> set = new HashSet<>();

    LinkedList<String> missingPackages = checkRegistry();

    Registry globalRegistry = EPackage.Registry.INSTANCE;

    // if not running in eclipse
    if (missingPackages.size() > 0) {

        // System.err.println("missing packages detected, adding them now...");

        RegisterMeta.registerPackages(EcorePackageImpl.eINSTANCE);
        RegisterMeta.registerPackages(XMLTypePackageImpl.eINSTANCE);
        RegisterMeta.registerPackages(Bpmn2Package.eINSTANCE);
        RegisterMeta.registerPackages(BpmnDiPackage.eINSTANCE);
        RegisterMeta.registerPackages(DiPackage.eINSTANCE);
        RegisterMeta.registerPackages(DcPackage.eINSTANCE);

        missingPackages = checkRegistry();
    }

    if (missingPackages.size() == 0) {

        set.add(new BPMNMetaModelResource(globalRegistry.getEPackage(
                "http://www.eclipse.org/emf/2003/XMLType").eResource(),
                this));

        set.add(new BPMNMetaModelResource(globalRegistry.getEPackage(
                "http://www.omg.org/spec/BPMN/20100524/MODEL-XMI")
                .eResource(), this));

        set.add(new BPMNMetaModelResource(globalRegistry.getEPackage(
                "http://www.omg.org/spec/DD/20100524/DC-XMI").eResource(),
                this));

        set.add(new BPMNMetaModelResource(globalRegistry.getEPackage(
                "http://www.eclipse.org/emf/2002/Ecore").eResource(), this));

        set.add(new BPMNMetaModelResource(
                globalRegistry.getEPackage(
                        "http://www.omg.org/spec/BPMN/20100524/DI-XMI")
                        .eResource(), this));

        set.add(new BPMNMetaModelResource(globalRegistry.getEPackage(
                "http://www.omg.org/spec/DD/20100524/DI-XMI").eResource(),
                this));

    } else {
        System.err
                .println("WARNING: one or more of the static metamodels of BPMN were not found, no static metamodels inserted for this plugin, please insert the relevant metamodels manually:\n"
                        + missingPackages.toString());
    }

    // System.err.println(set);

    return set;

}
项目:tool    文件:GraCommonAction.java   
static public void registerFactories(/*MDLog log*/){
        Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("xsd", xsdResourceFactory);
        Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("ecore", ecoreResourceFactory);
//      Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("sch", schematronResourceFactory);
    }
项目:emf.utils    文件:PackageRegistryView.java   
/**
 * The constructor.
 */
public PackageRegistryView() {
    registry = EPackage.Registry.INSTANCE;
}
项目:emfstore-rest    文件:EPackageRegistryHelper.java   
/**
 * Registers a EPackage in the EPackageRegistry.
 * 
 * @param pkg the EPackage to be registered
 */
public static void registerEPackage(EPackage pkg) {
    EPackage.Registry.INSTANCE.put(pkg.getNsURI(), pkg);
}
项目:emfstore-rest    文件:ModelMutatorUtil.java   
/**
 * Returns the EPackage to the specified <code>nsURI</code>.
 * 
 * @param nsURI
 *            the NsUri of the EPackage to get
 * @return the EPackage belonging to <code>nsURI</code>
 * @see Registry#getEPackage(String)
 */
public static EPackage getEPackage(String nsURI) {
    return EPackage.Registry.INSTANCE.getEPackage(nsURI);
}
项目:k3    文件:ModelGeneratorUtil.java   
/**
 * Returns the EPackage to the specified <code>nsURI</code>.
 * 
 * @param nsURI
 *            the NsUri of the EPackage to get
 * @return the EPackage belonging to <code>nsURI</code>
 * @see Registry#getEPackage(String)
 */
public  EPackage getEPackage(String nsURI) {
    return EPackage.Registry.INSTANCE.getEPackage(nsURI);
}