/**
  * create package from exported Packages
  *
  * @param bundleComponent the description of the bundle
  * @param bundleProject
  */
 public void fillExportedPackages(Component bundleComponent, Object bundleProject) {
   if (bundleProject instanceof IBundleProjectDescription) {
     IPackageExportDescription[] packageExportDescription =
         ((IBundleProjectDescription) bundleProject).getPackageExports();
     if (packageExportDescription != null) {
       ArrayList<EObject> exportedPackages = new ArrayList<EObject>();
       for (int i = 0; i < packageExportDescription.length; i++) {
         Package UMLPackage = UMLFactory.eINSTANCE.createPackage();
         UMLPackage.setName(packageExportDescription[i].getName());
         bundleComponent.getPackagedElements().add(UMLPackage);
         Stereotype exportedPackageStereotype =
             UMLPackage.getApplicableStereotype(
                 IADL4ECLIPSE_Stereotype.ECLIPSEEXPORTEDPACKAGE_STEREOTYPE);
         UMLPackage.applyStereotype(exportedPackageStereotype);
         UMLPackage.setValue(
             exportedPackageStereotype,
             IADL4ECLIPSE_Stereotype.ECLIPSEEXPORTEDPACKAGE_ISINTERNAL_ATT,
             !packageExportDescription[i].isApi());
         if (packageExportDescription[i].getVersion() != null) {
           UMLPackage.setValue(
               exportedPackageStereotype,
               IOSGIStereotype.VERSIONRANGE_ATLEAST_ATT,
               packageExportDescription[i].getVersion().toString());
         }
         exportedPackages.add(UMLPackage.getStereotypeApplication(exportedPackageStereotype));
       }
       Stereotype pluginStereotype =
           bundleComponent.getAppliedStereotype(IADL4ECLIPSE_Stereotype.PLUGIN_STEREOTYPE);
       bundleComponent.setValue(
           pluginStereotype, IOSGIStereotype.BUNDLE_EXPORTPACKAGE_ATT, exportedPackages);
     }
   }
 }
Пример #2
0
  @Override
  protected void setUp() {
    super.setUp();

    instanceResource = resourceSet.createResource(URI.createFileURI("/tmp/instances.uml"));

    instancePackage = umlf.createPackage();
    instancePackage.setName("instances");
    instanceResource.getContents().add(instancePackage);
  }
Пример #3
0
  /** Tests that unrecognized data types are represented by themselves, not by OclAny. */
  public void test_dataTypes_137158() {
    Package upackage = umlf.createPackage();
    upackage.setName("mypkg");
    Class uclass = upackage.createOwnedClass("B", false);
    DataType datatype = (DataType) pkg.createOwnedType("Thread", uml.getDataType());
    Operation operation = uclass.createOwnedOperation("f", null, null, datatype);
    operation.setIsQuery(true);

    helper.setContext(uclass);

    try {
      OCLExpression<Classifier> expr = helper.createQuery("self.f()");

      Classifier type = expr.getType();
      assertSame(datatype, type);

      operation.setUpper(LiteralUnlimitedNatural.UNLIMITED);

      expr = helper.createQuery("self.f()");

      type = expr.getType();
      assertTrue(type instanceof CollectionType<?, ?>);
      type = ((org.eclipse.ocl.uml.CollectionType) type).getElementType();
      assertSame(datatype, type);

      operation.setUpper(1);
      operation.setType(ocl.getEnvironment().getOCLStandardLibrary().getOclAny());

      expr = helper.createQuery("self.f()");

      type = expr.getType();
      assertSame(getOCLStandardLibrary().getOclAny(), type);
    } catch (Exception e) {
      fail("Failed to parse or evaluate: " + e.getLocalizedMessage());
    }
  }
Пример #4
0
 public Package createPackage(String name) {
   Package uPackage = UMLFactory.eINSTANCE.createPackage();
   uPackage.setName(name);
   return uPackage;
 }
 /**
  * Create a new instance of domain element associated with canvas.
  * <!-- begin-user-doc -->
  * <!-- end-user-doc -->
  *
  * @generated
  */
 private static Package createInitialModel(EClass initialObject, String diagramName) {
   Package diagram = (Package) UMLFactory.eINSTANCE.create(initialObject);
   diagram.setName(diagramName);
   return diagram;
 }
Пример #6
0
  @Override
  protected void setUp() {
    super.setUp();

    pkg = umlf.createPackage();
    pkg.setName("pkg");

    valueType = pkg.createOwnedPrimitiveType("Value");
    valueType
        .createOwnedOperation(
            "<",
            new BasicEList<String>(Collections.singleton("v")),
            new BasicEList<Type>(Collections.singleton(valueType)),
            getUMLBoolean())
        .setIsQuery(true);
    valueType
        .createOwnedOperation(
            "<=",
            new BasicEList<String>(Collections.singleton("v")),
            new BasicEList<Type>(Collections.singleton(valueType)),
            getUMLBoolean())
        .setIsQuery(true);
    valueType
        .createOwnedOperation(
            ">",
            new BasicEList<String>(Collections.singleton("v")),
            new BasicEList<Type>(Collections.singleton(valueType)),
            getUMLBoolean())
        .setIsQuery(true);
    valueType
        .createOwnedOperation(
            ">=",
            new BasicEList<String>(Collections.singleton("v")),
            new BasicEList<Type>(Collections.singleton(valueType)),
            getUMLBoolean())
        .setIsQuery(true);

    thingType = pkg.createOwnedClass("Thing", false);

    values = thingType.createOwnedAttribute("values", valueType);
    values.setUpper(LiteralUnlimitedNatural.UNLIMITED);
    values.setIsOrdered(true);
    values.setIsUnique(true);

    bdValue = thingType.createOwnedAttribute("bdValue", getEcoreBigDecimal());
    biValue = thingType.createOwnedAttribute("biValue", getEcoreBigInteger());

    numeroType = pkg.createOwnedClass("Numero", false);

    numeroType
        .createOwnedOperation(
            "+",
            new BasicEList<String>(Collections.singleton("n")),
            new BasicEList<Type>(Collections.singleton(numeroType)),
            numeroType)
        .setIsQuery(true);
    numeroType
        .createOwnedOperation(
            "-",
            new BasicEList<String>(Collections.singleton("n")),
            new BasicEList<Type>(Collections.singleton(numeroType)),
            numeroType)
        .setIsQuery(true);
    numeroType
        .createOwnedOperation(
            "*",
            new BasicEList<String>(Collections.singleton("n")),
            new BasicEList<Type>(Collections.singleton(numeroType)),
            numeroType)
        .setIsQuery(true);
    numeroType
        .createOwnedOperation(
            "/",
            new BasicEList<String>(Collections.singleton("n")),
            new BasicEList<Type>(Collections.singleton(numeroType)),
            numeroType)
        .setIsQuery(true);

    numeroType
        .createOwnedOperation(
            "-", ECollections.<String>emptyEList(), ECollections.<Type>emptyEList(), numeroType)
        .setIsQuery(true);

    numeroType
        .createOwnedOperation(
            "<",
            new BasicEList<String>(Collections.singleton("n")),
            new BasicEList<Type>(Collections.singleton(numeroType)),
            getUMLBoolean())
        .setIsQuery(true);
    numeroType
        .createOwnedOperation(
            "<=",
            new BasicEList<String>(Collections.singleton("n")),
            new BasicEList<Type>(Collections.singleton(numeroType)),
            getUMLBoolean())
        .setIsQuery(true);
    numeroType
        .createOwnedOperation(
            ">",
            new BasicEList<String>(Collections.singleton("n")),
            new BasicEList<Type>(Collections.singleton(numeroType)),
            getUMLBoolean())
        .setIsQuery(true);
    numeroType
        .createOwnedOperation(
            ">=",
            new BasicEList<String>(Collections.singleton("n")),
            new BasicEList<Type>(Collections.singleton(numeroType)),
            getUMLBoolean())
        .setIsQuery(true);
    numeroType
        .createOwnedOperation(
            "asLong",
            ECollections.<String>emptyEList(),
            ECollections.<Type>emptyEList(),
            getEcoreLong())
        .setIsQuery(true);

    numeros = thingType.createOwnedAttribute("numeros", numeroType);
    numeros.setUpper(LiteralUnlimitedNatural.UNLIMITED);
    numeros.setIsOrdered(true);
    numeros.setIsUnique(true);

    comparable = pkg.createOwnedClass("Comparable", true);
    comparable
        .createOwnedOperation(
            "compareTo",
            new BasicEList<String>(Collections.singleton("c")),
            new BasicEList<Type>(Collections.singleton(comparable)),
            getUMLInteger())
        .setIsQuery(true);

    // the Ecore counterpart

    epkg = UMLUtil.convertToEcore(pkg, null).iterator().next();

    ethingType = (EClass) epkg.getEClassifier(thingType.getName());
    enumeros = (EReference) ethingType.getEStructuralFeature(numeros.getName());
    evalues = (EAttribute) ethingType.getEStructuralFeature(values.getName());
    ebdValue = (EAttribute) ethingType.getEStructuralFeature(bdValue.getName());
    ebiValue = (EAttribute) ethingType.getEStructuralFeature(biValue.getName());

    enumeroType = (EClass) epkg.getEClassifier(numeroType.getName());
    enumeroType.setInstanceClass(Numero.class);

    evalueType = (EDataType) epkg.getEClassifier(valueType.getName());
    evalueType.setInstanceClass(Value.class);

    efactory = epkg.getEFactoryInstance();
    thing = efactory.create(ethingType);

    EPackage.Registry.INSTANCE.put(epkg.getNsURI(), epkg);

    @SuppressWarnings("unchecked")
    EList<Numero> list = (EList<Numero>) thing.eGet(enumeros);
    list.add(new Numero(6));
    list.add(new Numero(2));
  }