Package org.eclipse.emf.ecore.util

Examples of org.eclipse.emf.ecore.util.ExtendedMetaData


   * <!-- end-user-doc -->
   * @generated NOT
   */
  public EClassifier getEClassifier(String namespaceURI, String typeName)
  {
    ExtendedMetaData extendedMetaData = getExtendedMetaData();
    EPackage ePackage = extendedMetaData.getPackage(namespaceURI);
    if (ePackage != null)
    {
      EClassifier eClassifier = ePackage.getEClassifier(typeName);
      if (eClassifier == null)
      {
        eClassifier = extendedMetaData.getType(ePackage, typeName);
      }
      return eClassifier;
    }
    else
    {
View Full Code Here


        return "".equals(SDOExtendedMetaData.INSTANCE.getName((EClassifier)type));
    }

   
    public Type createType(HelperContext hc, String uri, String name, boolean isDataType) {
        ExtendedMetaData extendedMetaData = ((HelperContextImpl)hc).getExtendedMetaData();
        if ("".equals(uri))
            uri = null; // FB

        EPackage ePackage = extendedMetaData.getPackage(uri);
        if (ePackage == null) {
            ePackage = EcoreFactory.eINSTANCE.createEPackage();
            ePackage.setEFactoryInstance(new DynamicDataObjectImpl.FactoryImpl());
            ePackage.setNsURI(uri);
            String packagePrefix = uri != null ? URI.createURI(uri).trimFileExtension().lastSegment() : ""; // FB
            ePackage.setName(packagePrefix);
            ePackage.setNsPrefix(packagePrefix);
            extendedMetaData.putPackage(uri, ePackage);
        }

        EClassifier eClassifier = ePackage.getEClassifier(name);
        if (eClassifier != null) // already defined?
        {
View Full Code Here

  }
 
 
  public Property createOpenContentProperty(HelperContext hc, String uri, String name, Type type)
  {
        ExtendedMetaData extendedMetaData = ((HelperContextImpl)hc).getExtendedMetaData();

        // get/create document root
        EPackage ePackage = extendedMetaData.getPackage(uri);
        Type documentRoot = ePackage != null ? (Type)extendedMetaData.getType(ePackage, "") : null;
        if (documentRoot == null) {
            documentRoot = createType(hc, uri, null, false);
        }

        // Determine if property already exists
View Full Code Here

     {

        // Initialize the SDO runtime
        DataObjectUtil.initRuntime();
        EPackage.Registry packageRegistry = new EPackageRegistryImpl(EPackage.Registry.INSTANCE);
        ExtendedMetaData extendedMetaData = new BasicExtendedMetaData(packageRegistry);
        HelperContext context = new HelperContextImpl(extendedMetaData, false);
        XSDHelper xsdHelper = context.getXSDHelper();

        try {
           
            // Load the WSDL file
            File inputFile = new File(wsdlFileName).getAbsoluteFile();
            InputStream inputStream = new FileInputStream(inputFile);
           
            // Define SDO metadata
            xsdHelper.define(inputStream, inputFile.toURI().toString());

            if (targetDirectory == null) {
                targetDirectory = new File(wsdlFileName).getCanonicalFile().getParent();
            } else {
                targetDirectory = new File(targetDirectory).getCanonicalPath();
            }

            // Populate the typeMapping table that will be given to the Axis2 WSDL2Java
            Map<QName, SDODataBindingTypeMappingEntry> typeMapping =
                                    new HashMap<QName, SDODataBindingTypeMappingEntry>();
            if (!packageRegistry.values().isEmpty()) {
                ResourceSet resourceSet = DataObjectUtil.createResourceSet();

                // Populate list of GenPackages and a map of GenClasses keyed by EClass
                List<GenPackage> genPackages = new ArrayList<GenPackage>();
                Map<EClass, GenClass> genClasses = new HashMap<EClass, GenClass>();
                for (Iterator iter = packageRegistry.values().iterator(); iter.hasNext();) {
                    EPackage currentEPackage = (EPackage)iter.next();
                    String currentBasePackage = extractBasePackageName(currentEPackage, xsdJavaPackage);
                    String currentPrefix = CodeGenUtil.capName(currentEPackage.getName());

                    GenPackage currentGenPackage = createGenPackage(currentEPackage, currentBasePackage,
                                                                    currentPrefix, genOptions, resourceSet);
                    genPackages.add(currentGenPackage);
                    for (GenClass genClass : (List<GenClass>)currentGenPackage.getGenClasses()) {
                        genClasses.put(genClass.getEcoreClass(), genClass);
                    }

                }

                // Process all the SDO packages
                // Populate the qname -> interfaceName typeMapping table
                for (GenPackage currentGenPackage : genPackages) {
                    EPackage currentEPackage = currentGenPackage.getEcorePackage();
                   
                    // Populate the type mappings for all the complex types
                    for (GenClass genClass : (List<GenClass>)currentGenPackage.getGenClasses()) {
                        QName qname = new QName(extendedMetaData.getNamespace(currentEPackage),
                                                extendedMetaData.getName(genClass.getEcoreClass()));
                        String interfaceName = (DYNAMIC_SDO & genOptions) == DYNAMIC_SDO ? "commonj.sdo.DataObject" : currentGenPackage
                                .getInterfacePackageName()
                                + '.' + genClass.getInterfaceName();
                        SDODataBindingTypeMappingEntry typeMappingEntry =
                                new SDODataBindingTypeMappingEntry(interfaceName, false, null);
                        typeMapping.put(qname, typeMappingEntry);
                    }

                    // Process all the global XSD elements
                    EClass documentRoot = extendedMetaData.getDocumentRoot(currentEPackage);
                    if (documentRoot != null) {
                        for (EStructuralFeature element : (List<EStructuralFeature>)extendedMetaData
                            .getElements(documentRoot)) {
                            EClassifier elementType = element.getEType();
                           
                            // Handle a complex type
                            if (elementType instanceof EClass) {
                                EClass eClass = (EClass)elementType;

                                GenClass genClass = genClasses.get(elementType);
                                QName qname = new QName(extendedMetaData.getNamespace(currentEPackage),
                                        extendedMetaData.getName(element));
                                String interfaceName = (DYNAMIC_SDO & genOptions) == DYNAMIC_SDO ? "commonj.sdo.DataObject" : genClass
                                        .getGenPackage().getInterfacePackageName()
                                + '.' + genClass.getInterfaceName();
                                boolean anonymous = extendedMetaData.isAnonymous(eClass);
                               
                                // Build list of property class names
                                List<String> propertyClassNames=new ArrayList<String>();
                                for (EStructuralFeature feature : (List<EStructuralFeature>)eClass.getEStructuralFeatures()) {
                                    EClassifier propertyType = feature.getEType();
                                    if (propertyType instanceof EClass) {
                                        GenClass propertyGenClass = genClasses.get(propertyType);
                                        String propertyClassName = (DYNAMIC_SDO & genOptions) == DYNAMIC_SDO ? "commonj.sdo.DataObject"
                                                : propertyGenClass.getGenPackage().getInterfacePackageName() + '.'
                                                               + '.' + propertyGenClass.getInterfaceName();
                                        propertyClassNames.add(propertyClassName);
                                    } else if (propertyType instanceof EClassifier) {
                                        String propertyClassName = propertyType.getInstanceClass().getName();
                                        propertyClassNames.add(propertyClassName);
                                    }
                                }

                                SDODataBindingTypeMappingEntry typeMappingEntry =
                                    new SDODataBindingTypeMappingEntry(interfaceName, anonymous, propertyClassNames);
                                typeMapping.put(qname, typeMappingEntry);
                               
                            } else {
                               
                                // Handle a simple type
                                QName qname = new QName(extendedMetaData.getNamespace(currentEPackage),
                                                        extendedMetaData.getName(element));
                                String className = elementType.getInstanceClass().getName();
                                SDODataBindingTypeMappingEntry typeMappingEntry =
                                        new SDODataBindingTypeMappingEntry(className, false, null);
                                typeMapping.put(qname, typeMappingEntry);
                            }
View Full Code Here

     {

        // Initialize the SDO runtime
        DataObjectUtil.initRuntime();
        EPackage.Registry packageRegistry = new EPackageRegistryImpl(EPackage.Registry.INSTANCE);
        ExtendedMetaData extendedMetaData = new BasicExtendedMetaData(packageRegistry);
        XSDHelper xsdHelper = new XSDHelperImpl(extendedMetaData);

        try {
           
            // Load the WSDL file
            File inputFile = new File(wsdlFileName).getAbsoluteFile();
            InputStream inputStream = new FileInputStream(inputFile);
           
            // Define SDO metadata
            xsdHelper.define(inputStream, inputFile.toURI().toString());

            if (targetDirectory == null) {
                targetDirectory = new File(wsdlFileName).getCanonicalFile().getParent();
            } else {
                targetDirectory = new File(targetDirectory).getCanonicalPath();
            }

            // Populate the typeMapping table that will be given to the Axis2 WSDL2Java
            Map<QName, SDODataBindingTypeMappingEntry> typeMapping =
                                    new HashMap<QName, SDODataBindingTypeMappingEntry>();
            if (!packageRegistry.values().isEmpty()) {
                ResourceSet resourceSet = DataObjectUtil.createResourceSet();

                // Populate list of GenPackages and a map of GenClasses keyed by EClass
                List<GenPackage> genPackages = new ArrayList<GenPackage>();
                Map<EClass, GenClass> genClasses = new HashMap<EClass, GenClass>();
                for (Iterator iter = packageRegistry.values().iterator(); iter.hasNext();) {
                    EPackage currentEPackage = (EPackage)iter.next();
                    String currentBasePackage = extractBasePackageName(currentEPackage, xsdJavaPackage);
                    String currentPrefix = CodeGenUtil.capName(currentEPackage.getName());

                    GenPackage currentGenPackage = createGenPackage(currentEPackage, currentBasePackage,
                                                                    currentPrefix, genOptions, resourceSet);
                    genPackages.add(currentGenPackage);
                    for (GenClass genClass : (List<GenClass>)currentGenPackage.getGenClasses()) {
                        genClasses.put(genClass.getEcoreClass(), genClass);
                    }

                }

                // Process all the SDO packages
                // Populate the qname -> interfaceName typeMapping table
                for (GenPackage currentGenPackage : genPackages) {
                    EPackage currentEPackage = currentGenPackage.getEcorePackage();
                   
                    // Populate the type mappings for all the complex types
                    for (GenClass genClass : (List<GenClass>)currentGenPackage.getGenClasses()) {
                        QName qname = new QName(extendedMetaData.getNamespace(currentEPackage),
                                                extendedMetaData.getName(genClass.getEcoreClass()));
                        String interfaceName = currentGenPackage.getInterfacePackageName() + '.'
                                               + genClass.getInterfaceName();
                        SDODataBindingTypeMappingEntry typeMappingEntry =
                                new SDODataBindingTypeMappingEntry(interfaceName, false, null);
                        typeMapping.put(qname, typeMappingEntry);
                    }

                    // Process all the global XSD elements
                    EClass documentRoot = extendedMetaData.getDocumentRoot(currentEPackage);
                    if (documentRoot != null) {
                        for (EStructuralFeature element : (List<EStructuralFeature>)extendedMetaData
                            .getElements(documentRoot)) {
                            EClassifier elementType = element.getEType();
                           
                            // Handle a complex type
                            if (elementType instanceof EClass) {
                                EClass eClass = (EClass)elementType;

                                GenClass genClass = genClasses.get(elementType);
                                QName qname = new QName(extendedMetaData.getNamespace(currentEPackage),
                                        extendedMetaData.getName(element));
                                String interfaceName = genClass.getGenPackage().getInterfacePackageName()
                                + '.' + genClass.getInterfaceName();
                                boolean anonymous = extendedMetaData.isAnonymous(eClass);
                               
                                // Build list of property class names
                                List<String> propertyClassNames=new ArrayList<String>();
                                for (EStructuralFeature feature : (List<EStructuralFeature>)eClass.getEStructuralFeatures()) {
                                    EClassifier propertyType = feature.getEType();
                                    if (propertyType instanceof EClass) {
                                        GenClass propertyGenClass = genClasses.get(propertyType);
                                        String propertyClassName = propertyGenClass.getGenPackage().getInterfacePackageName()
                                                               + '.' + propertyGenClass.getInterfaceName();
                                        propertyClassNames.add(propertyClassName);
                                    } else if (propertyType instanceof EClassifier) {
                                        String propertyClassName = propertyType.getInstanceClass().getName();
                                        propertyClassNames.add(propertyClassName);
                                    }
                                }

                                SDODataBindingTypeMappingEntry typeMappingEntry =
                                    new SDODataBindingTypeMappingEntry(interfaceName, anonymous, propertyClassNames);
                                typeMapping.put(qname, typeMappingEntry);
                               
                            } else {
                               
                                // Handle a simple type
                                QName qname = new QName(extendedMetaData.getNamespace(currentEPackage),
                                                        extendedMetaData.getName(element));
                                String className = elementType.getInstanceClass().getName();
                                SDODataBindingTypeMappingEntry typeMappingEntry =
                                        new SDODataBindingTypeMappingEntry(className, false, null);
                                typeMapping.put(qname, typeMappingEntry);
                            }
View Full Code Here

    @Override
    public Resource createResource(URI uri) {
        DroolsFactoryImpl.init();
        BpsimFactoryImpl.init();
        JBPMBpmn2ResourceImpl result = new JBPMBpmn2ResourceImpl(uri);
        ExtendedMetaData extendedMetadata = new XmlExtendedMetadata();
        result.getDefaultSaveOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, extendedMetadata);
        result.getDefaultLoadOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, extendedMetadata);

        result.getDefaultSaveOptions().put(XMLResource.OPTION_SAVE_TYPE_INFORMATION,
                new OnlyContainmentTypeInfo());
View Full Code Here

                  String[] dataInputParts = dataInput.split( ":\\s*" );
                  if(dataInputParts.length == 2) {
                    nextInput.setId(sp.getId() + "_" + dataInputParts[0] + "InputX");
                    nextInput.setName(dataInputParts[0]);
                   
                    ExtendedMetaData metadata = ExtendedMetaData.INSTANCE;
                      EAttributeImpl extensionAttribute = (EAttributeImpl) metadata.demandFeature(
                              "http://www.jboss.org/drools", "dtype", false, false);
                      SimpleFeatureMapEntry extensionEntry = new SimpleFeatureMapEntry(extensionAttribute,
                          dataInputParts[1]);
                      nextInput.getAnyAttribute().add(extensionEntry);
                  } else {
                    nextInput.setId(sp.getId() + "_" + dataInput + "InputX");
                    nextInput.setName(dataInput);

                        ExtendedMetaData metadata = ExtendedMetaData.INSTANCE;
                        EAttributeImpl extensionAttribute = (EAttributeImpl) metadata.demandFeature(
                                "http://www.jboss.org/drools", "dtype", false, false);
                        SimpleFeatureMapEntry extensionEntry = new SimpleFeatureMapEntry(extensionAttribute,
                                "Object");
                        nextInput.getAnyAttribute().add(extensionEntry);
                  }
                 
                  sp.getIoSpecification().getDataInputs().add(nextInput);
                  inset.getDataInputRefs().add(nextInput);
              }
            }
            sp.getIoSpecification().getInputSets().add(inset);
        } else {
            if(sp.getIoSpecification() != null) {
              sp.getIoSpecification().getInputSets().add(Bpmn2Factory.eINSTANCE.createInputSet());
            }
        }
       
        // data output set
        if(properties.get("dataoutputset") != null && properties.get("dataoutputset").trim().length() > 0) {
            String[] allDataOutputs = properties.get("dataoutputset").split( ",\\s*" );
            if(sp.getIoSpecification() == null) {
                InputOutputSpecification iospec = Bpmn2Factory.eINSTANCE.createInputOutputSpecification();
                sp.setIoSpecification(iospec);
            }
           
            OutputSet outset = Bpmn2Factory.eINSTANCE.createOutputSet();
            for(String dataOutput : allDataOutputs) {
              if(dataOutput.trim().length() > 0) {
                  DataOutput nextOut = Bpmn2Factory.eINSTANCE.createDataOutput();
                  String[] dataOutputParts = dataOutput.split( ":\\s*" );
                  if(dataOutputParts.length == 2) {
                    nextOut.setId(sp.getId() + "_" + dataOutputParts[0] + "OutputX");
                    nextOut.setName(dataOutputParts[0]);
                   
                    ExtendedMetaData metadata = ExtendedMetaData.INSTANCE;
                      EAttributeImpl extensionAttribute = (EAttributeImpl) metadata.demandFeature(
                              "http://www.jboss.org/drools", "dtype", false, false);
                      SimpleFeatureMapEntry extensionEntry = new SimpleFeatureMapEntry(extensionAttribute,
                          dataOutputParts[1]);
                      nextOut.getAnyAttribute().add(extensionEntry);
                  } else {
                    nextOut.setId(sp.getId() + "_" + dataOutput + "OutputX");
                    nextOut.setName(dataOutput);

                        ExtendedMetaData metadata = ExtendedMetaData.INSTANCE;
                        EAttributeImpl extensionAttribute = (EAttributeImpl) metadata.demandFeature(
                                "http://www.jboss.org/drools", "dtype", false, false);
                        SimpleFeatureMapEntry extensionEntry = new SimpleFeatureMapEntry(extensionAttribute,
                                "Object");
                        nextOut.getAnyAttribute().add(extensionEntry);
                  }
View Full Code Here

       
    }
   
    protected void applyAssociationProperties(Association association, Map<String, String> properties) {
      if(properties.get("type") != null) {
        ExtendedMetaData metadata = ExtendedMetaData.INSTANCE;
            EAttributeImpl extensionAttribute = (EAttributeImpl) metadata.demandFeature(
                        "http://www.jboss.org/drools", "type", false, false);
            SimpleFeatureMapEntry extensionEntry = new SimpleFeatureMapEntry(extensionAttribute,
                properties.get("type"));
            association.getAnyAttribute().add(extensionEntry);
      }
View Full Code Here

        }

        boolean haveCustomType = false;

        if(properties.get("customtype") != null && properties.get("customtype").length() > 0) {
            ExtendedMetaData metadata = ExtendedMetaData.INSTANCE;
            EAttributeImpl extensionAttribute = (EAttributeImpl) metadata.demandFeature(
                    "http://www.jboss.org/drools", "datype", false, false);
            SimpleFeatureMapEntry extensionEntry = new SimpleFeatureMapEntry(extensionAttribute,
                    properties.get("customtype"));
            da.getAnyAttribute().add(extensionEntry);
            haveCustomType = true;
        }

        if(properties.get("standardtype") != null && properties.get("standardtype").length() > 0 && !haveCustomType) {
          ExtendedMetaData metadata = ExtendedMetaData.INSTANCE;
            EAttributeImpl extensionAttribute = (EAttributeImpl) metadata.demandFeature(
                        "http://www.jboss.org/drools", "datype", false, false);
            SimpleFeatureMapEntry extensionEntry = new SimpleFeatureMapEntry(extensionAttribute,
                properties.get("standardtype"));
            da.getAnyAttribute().add(extensionEntry);
        }
View Full Code Here

                _elementColors.get(ta.getId()).add("bordercolor:" + properties.get("bordercolor"));
            }
        }
       
        if(properties.get("fontsize") != null && properties.get("fontsize").length() > 0) {
          ExtendedMetaData metadata = ExtendedMetaData.INSTANCE;
          EAttributeImpl extensionAttribute = (EAttributeImpl) metadata.demandFeature(
              "http://www.jboss.org/drools", "fontsize", false, false);
          SimpleFeatureMapEntry extensionEntry = new SimpleFeatureMapEntry(extensionAttribute,
              properties.get("fontsize"));
          ta.getAnyAttribute().add(extensionEntry);
        }
View Full Code Here

TOP

Related Classes of org.eclipse.emf.ecore.util.ExtendedMetaData

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.