Java Code Examples for org.eclipse.emf.ecore.util.BasicExtendedMetaData

The following are top voted examples for showing how to use org.eclipse.emf.ecore.util.BasicExtendedMetaData. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: ATLauncher   File: ATLLauncher.java   Source Code and License 6 votes vote down vote up
private String lazyMetamodelRegistration(String metamodelPath){
	
	Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("ecore", new EcoreResourceFactoryImpl());
  	
    ResourceSet rs = new ResourceSetImpl();
    // Enables extended meta-data, weird we have to do this but well...
    final ExtendedMetaData extendedMetaData = new BasicExtendedMetaData(EPackage.Registry.INSTANCE);
    rs.getLoadOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, extendedMetaData);

    Resource r = rs.getResource(URI.createFileURI(metamodelPath), true);
    EObject eObject = r.getContents().get(0);
    // A meta-model might have multiple packages we assume the main package is the first one listed
    if (eObject instanceof EPackage) {
        EPackage p = (EPackage)eObject;
        System.out.println(p.getNsURI());
        EPackage.Registry.INSTANCE.put(p.getNsURI(), p);
        return p.getNsURI();
    }
    return null;
}
 
Example 2
Project: OpenSPIFe   File: EDataTypeStringifier.java   Source Code and License 6 votes vote down vote up
/**
 * @throws ParseException
 */
@Override
protected Object getJavaObjectFromTrimmed(String string, Object defaultObject) throws ParseException {
	try {
		if (eDataType.getInstanceClassName() != null 
				&& eDataType.getInstanceClassName().equalsIgnoreCase(BigDecimal.class.getName())) {
			double value = Double.parseDouble(string);
			BasicExtendedMetaData bemd = new BasicExtendedMetaData();
			int factionDigits = bemd.getFractionDigitsFacet(eDataType);
			String minInclusiveString = bemd.getMinInclusiveFacet(eDataType);
			if (minInclusiveString != null) {
				int minInclusive = Integer.parseInt(minInclusiveString);
				if (value < minInclusive) {
					value = 360 - Math.abs(value); // See SPF-9712
				}
			}
			return eFactoryInstance.createFromString(eDataType, String.format("%." + factionDigits + "f", value));
		}
		return eFactoryInstance.createFromString(eDataType, string);
	} catch (Exception e) {
		if (e instanceof ParseException) {
			throw (ParseException) e;
		}
		throw new ParseException(e.getMessage(), 0);
	}
}
 
Example 3
Project: NeoEMF   File: AbstractInputTest.java   Source Code and License 6 votes vote down vote up
/**
 * 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);
}
 
Example 4
Project: Tarski   File: persistenceResourceFactoryImpl.java   Source Code and License 5 votes vote down vote up
/**
 * Creates an instance of the resource factory. <!-- begin-user-doc --> <!-- end-user-doc -->
 * 
 * @generated
 */
public persistenceResourceFactoryImpl() {
  super();
  extendedMetaData =
      new BasicExtendedMetaData(new EPackageRegistryImpl(EPackage.Registry.INSTANCE));
  extendedMetaData.putPackage(null, persistencePackage.eINSTANCE);
}
 
Example 5
Project: NoSQLDataEngineering   File: ModelLoader.java   Source Code and License 5 votes vote down vote up
public ModelLoader()
{
	resourceSet = new ResourceSetImpl();
	final ExtendedMetaData extendedMetaData = 
		new BasicExtendedMetaData(resourceSet.getPackageRegistry());
	resourceSet.getLoadOptions().put(XMLResource.OPTION_EXTENDED_META_DATA,
	    extendedMetaData);
}
 
Example 6
Project: caml2tosca   File: ToscaUtil.java   Source Code and License 5 votes vote down vote up
public static void init(ResourceSet resourceSet, String path) {
	Resource_Set = resourceSet;
	Extended_Meta_Data = new BasicExtendedMetaData(resourceSet.getPackageRegistry());
	Package_Map = new HashMap<String, EPackage>();
	Text_Attribute = (EAttribute) XMLTypeFactory.eINSTANCE.createXMLTypeDocumentRoot().eClass().getEStructuralFeature("text");
	Path = path;
}
 
Example 7
Project: menthor-xcore   File: OntoumlResource.java   Source Code and License 5 votes vote down vote up
public static EPackage readEcore (String ecorePath)
{	
	ResourceSet ecoreResourceSet = new ResourceSetImpl();		
	URI ecoreURI = URI.createFileURI(ecorePath);		
	Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("ecore", new EcoreResourceFactoryImpl());
	ecoreResourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("ecore", new EcoreResourceFactoryImpl());
	ecoreResourceSet.getPackageRegistry().put(EcorePackage.eNS_URI, EcorePackage.eINSTANCE);				
	final ExtendedMetaData extendedMetaData = new BasicExtendedMetaData(ecoreResourceSet.getPackageRegistry());
	ecoreResourceSet.getLoadOptions().put(XMLResource.OPTION_EXTENDED_META_DATA,  extendedMetaData);		
    Resource ecoreResource = ecoreResourceSet.getResource(ecoreURI,true);
    EPackage ecoremodel = (EPackage) ecoreResource.getContents().get(0);	    
    ecoreResource.getResourceSet().getPackageRegistry().put(ecoremodel.getNsURI(),ecoremodel);
    EPackage.Registry.INSTANCE.put(ecoremodel.getNsURI(), ecoremodel);	    
    return ecoremodel;
}
 
Example 8
Project: WP3   File: persistenceResourceFactoryImpl.java   Source Code and License 5 votes vote down vote up
/**
 * Creates an instance of the resource factory. <!-- begin-user-doc --> <!-- end-user-doc -->
 * 
 * @generated
 */
public persistenceResourceFactoryImpl() {
  super();
  extendedMetaData =
      new BasicExtendedMetaData(new EPackageRegistryImpl(EPackage.Registry.INSTANCE));
  extendedMetaData.putPackage(null, persistencePackage.eINSTANCE);
}
 
Example 9
Project: massif   File: Exporter.java   Source Code and License 5 votes vote down vote up
/**
 * Loads the EMF representation of a Simulink model.
 * 
 * @param fileNameWithoutExtension
 *            the file to load specified by its name
 * @return the loaded SimulinkModel root EMF model object
 * @throws SimulinkApiException
 */
public SimulinkModel loadSimulinkModel(String fileNameWithoutExtension) throws SimulinkApiException {

    // Register a resource factory for the extension "simulink"
    Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE;
    Map<String, Object> m = reg.getExtensionToFactoryMap();
    m.put("simulink", new XMIResourceFactoryImpl());

    // Obtain a new resource set
    ResourceSet rs = new ResourceSetImpl();
    final ExtendedMetaData extendedMetaData = new BasicExtendedMetaData(rs.getPackageRegistry());
    rs.getLoadOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, extendedMetaData);

    // The model will be saved to the root of the project for now under the
    // given name.
    // TODO save path may come from an extension or properties file
    String path = fileNameWithoutExtension + ".simulink";

    // Load the resource
    Resource loadResource = rs.getResource(URI.createURI(path), true);
    Object resourceContent = loadResource.getContents().get(0);

    // Make a log entry if the root object isn't a SimulinkModel
    if (!(resourceContent instanceof SimulinkModel))
        logger.error("The given resource contained no SimulinkModel as a root element!");

    // Return the root EMF model object
    // Also throws an exception when invalid cast occurs
    return (SimulinkModel) resourceContent;
}
 
Example 10
Project: emfviews   File: TestEMFViews.java   Source Code and License 5 votes vote down vote up
@Before
public void setup() {
  // We need the TOGAF model for some of the tests, but the plugin has no update site.
  // Instead, we use the Ecore file in resources/metamodels.  However, while EMFViews works
  // with the Ecore file, the code in EclDelegate assumes that metamodels are registered in
  // the EMF package registry.
  //
  // To work around this issue, we load the EPackage from the Ecore file into the package registry.
  //
  // See: https://stackoverflow.com/a/9389901

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

  ResourceSet rs = new ResourceSetImpl();
  // enable extended metadata
  final ExtendedMetaData extendedMetaData = new BasicExtendedMetaData(rs.getPackageRegistry());
  rs.getLoadOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, extendedMetaData);

  Resource r = rs.getResource(resourceURI("metamodels/contentfwk.ecore"), true);
  EObject eObject = r.getContents().get(0);
  if (eObject instanceof EPackage) {
    EPackage p = (EPackage) eObject;
    EPackage.Registry.INSTANCE.put(p.getNsURI(), p);
  } else {
    throw new IllegalStateException("Error loading TOGAF metamodel for testing");
  }
}
 
Example 11
Project: eclipse-avro   File: EPackageImpl.java   Source Code and License 4 votes vote down vote up
public BasicExtendedMetaData.EPackageExtendedMetaData getExtendedMetaData()
{
  return ePackageExtendedMetaData;
}
 
Example 12
Project: eclipse-avro   File: EPackageImpl.java   Source Code and License 4 votes vote down vote up
public void setExtendedMetaData(BasicExtendedMetaData.EPackageExtendedMetaData ePackageExtendedMetaData)
{
  this.ePackageExtendedMetaData = ePackageExtendedMetaData;
}
 
Example 13
Project: eclipse-avro   File: EClassifierImpl.java   Source Code and License 4 votes vote down vote up
public BasicExtendedMetaData.EClassifierExtendedMetaData getExtendedMetaData()
{
  return eClassifierExtendedMetaData;
}
 
Example 14
Project: eclipse-avro   File: EClassifierImpl.java   Source Code and License 4 votes vote down vote up
public void setExtendedMetaData(BasicExtendedMetaData.EClassifierExtendedMetaData eClassifierExtendedMetaData)
{
  this.eClassifierExtendedMetaData = eClassifierExtendedMetaData;
}
 
Example 15
Project: eclipse-avro   File: EStructuralFeatureImpl.java   Source Code and License 4 votes vote down vote up
public BasicExtendedMetaData.EStructuralFeatureExtendedMetaData getExtendedMetaData()
{
  return eStructuralFeatureExtendedMetaData;
}
 
Example 16
Project: eclipse-avro   File: EStructuralFeatureImpl.java   Source Code and License 4 votes vote down vote up
public void setExtendedMetaData(BasicExtendedMetaData.EStructuralFeatureExtendedMetaData eStructuralFeatureExtendedMetaData)
{
  this.eStructuralFeatureExtendedMetaData = eStructuralFeatureExtendedMetaData;
}
 
Example 17
Project: clickwatch   File: EPackageImpl.java   Source Code and License 4 votes vote down vote up
public BasicExtendedMetaData.EPackageExtendedMetaData getExtendedMetaData()
{
  return ePackageExtendedMetaData;
}
 
Example 18
Project: clickwatch   File: EPackageImpl.java   Source Code and License 4 votes vote down vote up
public void setExtendedMetaData(BasicExtendedMetaData.EPackageExtendedMetaData ePackageExtendedMetaData)
{
  this.ePackageExtendedMetaData = ePackageExtendedMetaData;
}
 
Example 19
Project: clickwatch   File: EClassifierImpl.java   Source Code and License 4 votes vote down vote up
public BasicExtendedMetaData.EClassifierExtendedMetaData getExtendedMetaData()
{
  return eClassifierExtendedMetaData;
}
 
Example 20
Project: clickwatch   File: EClassifierImpl.java   Source Code and License 4 votes vote down vote up
public void setExtendedMetaData(BasicExtendedMetaData.EClassifierExtendedMetaData eClassifierExtendedMetaData)
{
  this.eClassifierExtendedMetaData = eClassifierExtendedMetaData;
}
 
Example 21
Project: clickwatch   File: EStructuralFeatureImpl.java   Source Code and License 4 votes vote down vote up
public BasicExtendedMetaData.EStructuralFeatureExtendedMetaData getExtendedMetaData()
{
  return eStructuralFeatureExtendedMetaData;
}
 
Example 22
Project: clickwatch   File: EStructuralFeatureImpl.java   Source Code and License 4 votes vote down vote up
public void setExtendedMetaData(BasicExtendedMetaData.EStructuralFeatureExtendedMetaData eStructuralFeatureExtendedMetaData)
{
  this.eStructuralFeatureExtendedMetaData = eStructuralFeatureExtendedMetaData;
}
 
Example 23
Project: hybris-commerce-eclipse-plugin   File: BeansResourceFactoryImpl.java   Source Code and License 2 votes vote down vote up
/**
 * Creates an instance of the resource factory.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public BeansResourceFactoryImpl() {
	super();
	extendedMetaData = new BasicExtendedMetaData(new EPackageRegistryImpl(EPackage.Registry.INSTANCE));
	extendedMetaData.putPackage(null, BeansPackage.eINSTANCE);
}
 
Example 24
Project: tug_qt_unit_testing_fw   File: Qt48XmlschemaQwtEnhancedResourceFactoryImpl.java   Source Code and License 2 votes vote down vote up
/**
 * Creates an instance of the resource factory.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public Qt48XmlschemaQwtEnhancedResourceFactoryImpl() {
	super();
	extendedMetaData = new BasicExtendedMetaData(new EPackageRegistryImpl(EPackage.Registry.INSTANCE));
	extendedMetaData.putPackage(null, Qt48XmlschemaQwtEnhancedPackage.eINSTANCE);
}
 
Example 25
Project: tug_qt_unit_testing_fw   File: Qt48XmlSchemaResourceFactoryImpl.java   Source Code and License 2 votes vote down vote up
/**
 * Creates an instance of the resource factory.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public Qt48XmlSchemaResourceFactoryImpl() {
	super();
	extendedMetaData = new BasicExtendedMetaData(new EPackageRegistryImpl(EPackage.Registry.INSTANCE));
	extendedMetaData.putPackage(null, Qt48XmlSchemaPackage.eINSTANCE);
}
 
Example 26
Project: tug_qt_unit_testing_fw   File: Qt48XmlschemaResourceFactoryImpl.java   Source Code and License 2 votes vote down vote up
/**
 * Creates an instance of the resource factory.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public Qt48XmlschemaResourceFactoryImpl() {
	super();
	extendedMetaData = new BasicExtendedMetaData(new EPackageRegistryImpl(EPackage.Registry.INSTANCE));
	extendedMetaData.putPackage(null, Qt48XmlschemaPackage.eINSTANCE);
}
 
Example 27
Project: OpenSPIFe   File: EsmConfigResourceFactoryImpl.java   Source Code and License 2 votes vote down vote up
/**
 * Creates an instance of the resource factory.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public EsmConfigResourceFactoryImpl() {
	super();
	extendedMetaData = new BasicExtendedMetaData(new EPackageRegistryImpl(EPackage.Registry.INSTANCE));
	extendedMetaData.putPackage(null, EsmConfigPackage.eINSTANCE);
}
 
Example 28
Project: pnmlframework   File: NupnResourceFactoryImpl.java   Source Code and License 2 votes vote down vote up
/**
 * Creates an instance of the resource factory.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public NupnResourceFactoryImpl() {
	super();
	extendedMetaData = new BasicExtendedMetaData(new EPackageRegistryImpl(EPackage.Registry.INSTANCE));
	extendedMetaData.putPackage(null, NupnPackage.eINSTANCE);
}
 
Example 29
Project: tool   File: CatalogResourceFactoryImpl.java   Source Code and License 2 votes vote down vote up
/**
 * Creates an instance of the resource factory.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public CatalogResourceFactoryImpl() {
	super();
	extendedMetaData = new BasicExtendedMetaData(new EPackageRegistryImpl(EPackage.Registry.INSTANCE));
	extendedMetaData.putPackage(null, CatalogPackage.eINSTANCE);
}