Esempio n. 1
0
 @Override
 public <@NonNull T extends NamedElement> T refreshElement(
     @NonNull Class<T> pivotClass, EClass pivotEClass, @NonNull EModelElement eModelElement) {
   EObject pivotElement = null;
   if (oldIdMap != null) {
     String id = ((XMLResource) eModelElement.eResource()).getID(eModelElement);
     if (id != null) {
       pivotElement = oldIdMap.get(id);
       if ((pivotElement != null) && (pivotElement.eClass() != pivotEClass)) {
         pivotElement = null;
       }
     }
   }
   if (pivotElement == null) {
     EFactory eFactoryInstance = pivotEClass.getEPackage().getEFactoryInstance();
     pivotElement = eFactoryInstance.create(pivotEClass);
   }
   if (!pivotClass.isAssignableFrom(pivotElement.getClass())) {
     throw new ClassCastException();
   }
   @SuppressWarnings("unchecked")
   T castElement = (T) pivotElement;
   Element oldElement = newCreateMap.put(eModelElement, castElement);
   assert oldElement == null;
   return castElement;
 }
Esempio n. 2
0
 /**
  *
  * <!-- begin-user-doc -->
  * <!-- end-user-doc -->
  *
  * @generated
  */
 public IComment addComment() {
   org.eclipse.emf.ecore.EPackage ePackage =
       org.eclipse.emf.ecore.EPackage.Registry.INSTANCE.getEPackage(
           "http://www.openhealthtools.org/mdht/uml/cda/apitest");
   org.eclipse.emf.ecore.EFactory eFactory =
       org.eclipse.emf.ecore.EPackage.Registry.INSTANCE.getEFactory(
           "http://www.openhealthtools.org/mdht/uml/cda/apitest");
   org.eclipse.emf.ecore.EClass eClass =
       (org.eclipse.emf.ecore.EClass) ePackage.getEClassifier("Comment");
   org.eclipse.emf.ecore.EObject eObject = eFactory.create(eClass);
   try {
     java.lang.reflect.Method initMethod =
         eObject.getClass().getMethod("init", new java.lang.Class[0]);
     initMethod.invoke(eObject, new Object[0]);
   } catch (Exception e) {
     // no init() method
   }
   org.eclipse.emf.ecore.EPackage domainPackage = this.eClass().getEPackage();
   org.eclipse.emf.ecore.EFactory domainFactory = domainPackage.getEFactoryInstance();
   org.eclipse.emf.ecore.EClass domainEClass =
       (org.eclipse.emf.ecore.EClass) domainPackage.getEClassifier("IComment");
   IComment value = (IComment) domainFactory.create(domainEClass);
   value.setCDAType((org.openhealthtools.mdht.uml.cda.Act) eObject);
   this.getCDAType().addAct((org.openhealthtools.mdht.uml.cda.Act) eObject);
   return value;
 }
 /**
  * {@inheritDoc}
  *
  * @see
  *     org.eclipse.emfforms.spi.spreadsheet.core.converter.EMFFormsSpreadsheetValueConverter#setCellValue(org.apache.poi.ss.usermodel.Cell,
  *     java.lang.Object, org.eclipse.emf.ecore.EStructuralFeature,
  *     org.eclipse.emf.ecp.view.spi.context.ViewModelContext)
  */
 @Override
 public void setCellValue(
     Cell cell,
     Object fromObject,
     EStructuralFeature eStructuralFeature,
     ViewModelContext viewModelContext)
     throws EMFFormsConverterException {
   final EDataType eDataType = EAttribute.class.cast(eStructuralFeature).getEAttributeType();
   final EFactory eFactory = eDataType.getEPackage().getEFactoryInstance();
   final StringBuilder result = new StringBuilder();
   for (final Object value : (List<?>) fromObject) {
     if (result.length() != 0) {
       result.append(SEPARATOR);
     }
     result.append(eFactory.convertToString(eDataType, value));
   }
   String valueString = result.toString();
   if (isDecimalNumber(eDataType.getInstanceClass())) {
     valueString =
         valueString.replace(
             '.',
             DecimalFormatSymbols.getInstance(localeProvider.getLocale()).getDecimalSeparator());
   }
   cell.setCellValue(valueString);
   cell.setCellStyle(
       (CellStyle) viewModelContext.getContextValue(EMFFormsCellStyleConstants.TEXT));
 }
Esempio n. 4
0
 /**
  * Get the value of the named AD parameter for the activity as a string. Works with several types,
  * not just strings -- enums, for example.
  *
  * @param element
  * @param parameterName
  * @return null if the parameter is not found
  */
 public static String getParameterString(EPlanElement element, String parameterName) {
   EObject data = element.getData();
   if (data == null) return null;
   EStructuralFeature feature;
   try {
     feature = getParameterFeature(data, parameterName);
   } catch (UndefinedParameterException e) {
     return null;
   }
   Object object = data.eGet(feature);
   if (object instanceof EEnumLiteral) {
     EEnumLiteral literal = (EEnumLiteral) object;
     return literal.getName();
   }
   EClassifier type = feature.getEType();
   if (type instanceof EDataType) {
     EDataType dataType = (EDataType) type;
     EPackage typePackage = dataType.getEPackage();
     EFactory factory = typePackage.getEFactoryInstance();
     String string = factory.convertToString(dataType, object);
     return string;
   }
   LogUtil.warnOnce("feature type '" + type + "'is not EDataType: " + parameterName);
   return String.valueOf(object);
 }
Esempio n. 5
0
  private void createModel() {
    EFactory factory = metamodelPackage.getEFactoryInstance();
    netObject = factory.create(getNetClass());

    place1Object = factory.create(getPlaceClass());
    setName(place1Object, "place1");
    setTokens(place1Object, 1);

    place2Object = factory.create(getPlaceClass());
    setName(place2Object, "place2");

    transitionObject = factory.create(getTransitionClass());
    setIncoming(transitionObject, place1Object);
    setOutgoing(transitionObject, place2Object);

    EList<EObject> placesValue = new BasicEList<EObject>();
    placesValue.add(place1Object);
    placesValue.add(place2Object);
    EReference placesReference = getPlacesReference(netObject.eClass());
    netObject.eSet(placesReference, placesValue);

    EList<EObject> transitionsValue = new BasicEList<EObject>();
    transitionsValue.add(transitionObject);
    EReference transitionsReference = getTransitionsReference(netObject.eClass());
    netObject.eSet(transitionsReference, transitionsValue);
  }
 /**
  *
  * <!-- begin-user-doc -->
  * <!-- end-user-doc -->
  *
  * @generated
  */
 public CD withValue() {
   org.eclipse.emf.ecore.EPackage ePackage =
       org.openhealthtools.mdht.uml.hl7.datatypes.DatatypesPackage.eINSTANCE;
   org.eclipse.emf.ecore.EFactory eFactory =
       org.openhealthtools.mdht.uml.hl7.datatypes.DatatypesFactory.eINSTANCE;
   org.eclipse.emf.ecore.EClass eClass =
       (org.eclipse.emf.ecore.EClass) ePackage.getEClassifier("CD");
   org.eclipse.emf.ecore.EObject eObject = eFactory.create(eClass);
   CD value = (CD) eObject;
   this.getCDAType().getValues().add(value);
   return value;
 }
Esempio n. 7
0
 /**
  *
  * <!-- begin-user-doc -->
  * <!-- end-user-doc -->
  *
  * @generated
  */
 public ED withProblemName() {
   org.eclipse.emf.ecore.EPackage ePackage =
       org.openhealthtools.mdht.uml.hl7.datatypes.DatatypesPackage.eINSTANCE;
   org.eclipse.emf.ecore.EFactory eFactory =
       org.openhealthtools.mdht.uml.hl7.datatypes.DatatypesFactory.eINSTANCE;
   org.eclipse.emf.ecore.EClass eClass =
       (org.eclipse.emf.ecore.EClass) ePackage.getEClassifier("ED");
   org.eclipse.emf.ecore.EObject eObject = eFactory.create(eClass);
   ED value = (ED) eObject;
   this.getCDAType().setText(value);
   return value;
 }
Esempio n. 8
0
 /**
  *
  * <!-- begin-user-doc -->
  * <!-- end-user-doc -->
  *
  * @generated
  */
 public IVL_TS withProblemDate() {
   org.eclipse.emf.ecore.EPackage ePackage =
       org.openhealthtools.mdht.uml.hl7.datatypes.DatatypesPackage.eINSTANCE;
   org.eclipse.emf.ecore.EFactory eFactory =
       org.openhealthtools.mdht.uml.hl7.datatypes.DatatypesFactory.eINSTANCE;
   org.eclipse.emf.ecore.EClass eClass =
       (org.eclipse.emf.ecore.EClass) ePackage.getEClassifier("IVL_TS");
   org.eclipse.emf.ecore.EObject eObject = eFactory.create(eClass);
   IVL_TS value = (IVL_TS) eObject;
   this.getCDAType().setEffectiveTime(value);
   return value;
 }
Esempio n. 9
0
 public static IntermediateClassFactory getFactory(Module module) {
   for (EPackage subPackage : module.getESubpackages()) {
     // should be fast we will always have a single and the only
     // intermediate package
     if (isIntermediatePackage(subPackage)) {
       EFactory eFactory = subPackage.getEFactoryInstance();
       if (eFactory.getClass().equals(IntermediateClassFactory.class)) {
         return (IntermediateClassFactory) eFactory;
       }
     }
   }
   return null;
 }
Esempio n. 10
0
 /**
  * Use setParameterString instead, unless calling from an XML loader that has not yet created the
  * plan element.
  */
 public static void setParameterStringInData(EObject data, String parameterName, String newValue)
     throws UndefinedParameterException {
   EStructuralFeature feature = getParameterFeature(data, parameterName);
   EClassifier type = feature.getEType();
   Object object;
   if (type instanceof EEnum) {
     EEnum enumType = (EEnum) type;
     object = enumType.getEEnumLiteral(newValue);
   } else if (type instanceof EDataType) {
     EDataType dataType = (EDataType) type;
     EPackage typePackage = dataType.getEPackage();
     EFactory factory = typePackage.getEFactoryInstance();
     object = factory.createFromString(dataType, newValue);
   } else {
     Logger logger = Logger.getLogger(ADParameterUtils.class);
     logger.warn("feature type '" + type + "'is not EDataType: " + parameterName);
     object = newValue;
   }
   data.eSet(feature, object);
 }
  /**
   * {@inheritDoc}
   *
   * @see
   *     org.eclipse.emfforms.spi.spreadsheet.core.converter.EMFFormsSpreadsheetValueConverter#getCellValue(org.apache.poi.ss.usermodel.Cell,
   *     org.eclipse.emf.ecore.EStructuralFeature)
   */
  @Override
  public Object getCellValue(Cell cell, EStructuralFeature eStructuralFeature)
      throws EMFFormsConverterException {
    String string;
    try {
      string = cell.getStringCellValue();
    } catch (final IllegalStateException e) {
      throw new EMFFormsConverterException(
          String.format(
              "Cell value of column %1$s in row %2$s on sheet %3$s must be a string.", //$NON-NLS-1$
              cell.getColumnIndex() + 1, cell.getRowIndex() + 1, cell.getSheet().getSheetName()),
          e);
    }

    if (string == null || string.length() == 0) {
      return Collections.emptyList();
    }
    final EAttribute eAttribute = EAttribute.class.cast(eStructuralFeature);
    final EDataType eDataType = eAttribute.getEAttributeType();
    if (isDecimalNumber(eDataType.getInstanceClass())) {
      string =
          string.replace(
              DecimalFormatSymbols.getInstance(localeProvider.getLocale()).getDecimalSeparator(),
              '.');
    }

    final List<Object> result = new ArrayList<Object>();
    final EFactory eFactory = eDataType.getEPackage().getEFactoryInstance();
    for (final String element : string.split(SEPARATOR)) {
      try {
        result.add(eFactory.createFromString(eDataType, element));
      } // BEGIN SUPRESS CATCH EXCEPTION
      catch (final RuntimeException ex) { // END SUPRESS CATCH EXCEPTION
        throw new EMFFormsConverterException(
            MessageFormat.format(
                "The cell value {0} could not converted to a model value.", string)); // $NON-NLS-1$
      }
    }

    return result;
  }
Esempio n. 12
0
 /**
  * Add a value to a named AD multi-select EEnum parameter for the activity
  *
  * @param element
  * @param parameterName
  * @param newValue
  * @throws UndefinedParameterException
  */
 @SuppressWarnings("unchecked")
 public static void addParameterStringToList(
     EPlanElement element, String parameterName, String newValue)
     throws UndefinedParameterException {
   EObject data = element.getData();
   EStructuralFeature feature = getParameterFeature(data, parameterName);
   EClassifier type = feature.getEType();
   Object object;
   if (type instanceof EEnum) {
     EEnum enumType = (EEnum) type;
     object = enumType.getEEnumLiteral(newValue);
   } else if (type instanceof EDataType) {
     EDataType dataType = (EDataType) type;
     EPackage typePackage = dataType.getEPackage();
     EFactory factory = typePackage.getEFactoryInstance();
     object = factory.createFromString(dataType, newValue);
   } else {
     Logger logger = Logger.getLogger(ADParameterUtils.class);
     logger.warn("feature type '" + type + "'is not EDataType: " + parameterName);
     object = newValue;
   }
   addParameterObjectToList(element, parameterName, object);
 }
Esempio n. 13
0
  /**
   * Clones an eobject, with the option of performing a deep clone in which referenced eobjects are
   * also cloned.
   *
   * @param prototype The object to be cloned from.
   * @param factory The factory used to create the clone.
   * @param deepÊFlag indicating wether to perform a deep clone.
   * @return THe cloned object, with all properties the same to the original.
   */
  public static EObject clone(EObject prototype, EFactory factory, boolean deep) {
    EObject clone = factory.create(prototype.eClass());

    for (Iterator i = clone.eClass().getEStructuralFeatures().iterator(); i.hasNext(); ) {
      EStructuralFeature feature = (EStructuralFeature) i.next();
      Object value = prototype.eGet(feature);
      if (deep && value instanceof EObject) {
        EObject evalue = (EObject) value;
        // recursively call
        // TODO:handle cycles in reference graph
        value = clone(evalue, evalue.eClass().getEPackage().getEFactoryInstance(), deep);
      }

      clone.eSet(feature, value);
    }

    return clone;
  }
 @Override
 public TreeIterator<EObject> eAllContents() {
   // TODO Auto-generated method stub
   return delegate.eAllContents();
 }
 @Override
 public EList<EObject> eContents() {
   // TODO Auto-generated method stub
   return delegate.eContents();
 }
 @Override
 public EReference eContainmentFeature() {
   // TODO Auto-generated method stub
   return delegate.eContainmentFeature();
 }
 @Override
 public EStructuralFeature eContainingFeature() {
   // TODO Auto-generated method stub
   return delegate.eContainingFeature();
 }
 @Override
 public EObject eContainer() {
   // TODO Auto-generated method stub
   return delegate.eContainer();
 }
 @Override
 public Resource eResource() {
   // TODO Auto-generated method stub
   return delegate.eResource();
 }
 @Override
 public void eNotify(Notification notification) {
   delegate.eNotify(notification);
 }
 @Override
 public boolean eDeliver() {
   // TODO Auto-generated method stub
   return delegate.eDeliver();
 }
 @Override
 public EObject create(EClass eClass) {
   if (EMFModelManager.replacedClasses.contains(eClass))
     return eClass.getEPackage().getEFactoryInstance().create(eClass);
   return delegate.create(eClass);
 }
 @Override
 public Object createFromString(EDataType eDataType, String literalValue) {
   // TODO Auto-generated method stub
   return delegate.createFromString(eDataType, literalValue);
 }
 @Override
 public void setEPackage(EPackage value) {
   delegate.setEPackage(value);
 }
 @Override
 public EList<Adapter> eAdapters() {
   // TODO Auto-generated method stub
   return delegate.eAdapters();
 }
 @Override
 public EClass eClass() {
   // TODO Auto-generated method stub
   return delegate.eClass();
 }
 @Override
 public EList<EAnnotation> getEAnnotations() {
   // TODO Auto-generated method stub
   return delegate.getEAnnotations();
 }
 @Override
 public void eSetDeliver(boolean deliver) {
   delegate.eSetDeliver(deliver);
 }
 @Override
 public String convertToString(EDataType eDataType, Object instanceValue) {
   // TODO Auto-generated method stub
   return delegate.convertToString(eDataType, instanceValue);
 }
 @Override
 public EAnnotation getEAnnotation(String source) {
   // TODO Auto-generated method stub
   return delegate.getEAnnotation(source);
 }