Beispiel #1
0
  /** @generated NOT */
  public KleisliModel kleisliCreateType(KleisliModelEndpoint containerModelTypeEndpoint)
      throws MMINTException {

    // TODO MMINT[KLEISLI] should try to emulate normal api structure
    if (MultiModelConstraintChecker.isInstancesLevel(this)) {
      throw new MMINTException("Can't execute TYPES level operation on INSTANCES level element");
    }

    Model origModelType = containerModelTypeEndpoint.getTarget();
    String kModelTypeUri =
        getModelTypeExtendedUri(
            (KleisliModelRel) containerModelTypeEndpoint.eContainer(),
            origModelType,
            containerModelTypeEndpoint.getName());
    if (!MultiModelUtils.isFileOrDirectoryInState(kModelTypeUri)) {
      try {
        EPackage origRootModelTypeObj = origModelType.getEMFTypeRoot();
        String origModelTypeUri = origRootModelTypeObj.getNsURI();
        origRootModelTypeObj.setNsURI(
            origModelTypeUri + KleisliReasoningEngine.KLEISLI_MODELTYPE_URI_SUFFIX);
        MultiModelUtils.createModelFileInState(origRootModelTypeObj, kModelTypeUri);
        origRootModelTypeObj.setNsURI(
            origModelTypeUri); // restore original for packages coming from the registry
      } catch (Exception e) {
        throw new MMINTException("Error creating extended metamodel file");
      }
    }

    KleisliModel kModelType = KleisliFactory.eINSTANCE.createKleisliModel();
    kModelType.setUri(kModelTypeUri);
    kModelType.setName(origModelType.getName());
    kModelType.setLevel(MIDLevel.TYPES);
    kModelType.setSupertype(origModelType.getSupertype());
    kModelType.setDynamic(true);
    kModelType.setAbstract(origModelType.isAbstract());
    ExtendibleElementConstraint origConstraint = origModelType.getConstraint();
    if (origConstraint != null) {
      ExtendibleElementConstraint kConstraint =
          MIDFactory.eINSTANCE.createExtendibleElementConstraint();
      kConstraint.setLanguage(origConstraint.getLanguage());
      kConstraint.setImplementation(origConstraint.getImplementation());
      kModelType.setConstraint(kConstraint);
    }
    kModelType.setOrigin(ModelOrigin.CREATED);
    kModelType.setFileExtension(origModelType.getFileExtension());
    containerModelTypeEndpoint.setExtendedTarget(kModelType);

    return kModelType;
  }
Beispiel #2
0
  /** @generated NOT */
  @Override
  public void deleteInstance() throws MMINTException {

    if (!MultiModelConstraintChecker.isInstancesLevel(this)) {
      throw new MMINTException("Can't execute INSTANCES level operation on TYPES level element");
    }

    MultiModelUtils.deleteFile(getUri(), true);
  }
Beispiel #3
0
  /** @generated NOT */
  @Override
  public EPackage getEMFTypeRoot() throws MMINTException {

    if (MultiModelConstraintChecker.isInstancesLevel(this)) {
      throw new MMINTException("Can't execute TYPES level operation on INSTANCES level element");
    }

    try {
      return (EPackage) MultiModelUtils.getModelFileInState(getUri());
    } catch (Exception e) {
      throw new MMINTException(
          "Error accessing the extended metamodel file for model type" + getUri(), e);
    }
  }