Exemple #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;
  }
Exemple #2
0
  /** @generated NOT */
  public KleisliModel kleisliCreateInstance(KleisliModelEndpoint containerModelEndpoint)
      throws MMINTException {

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

    Model origModel = containerModelEndpoint.getTarget();
    KleisliModel kModel = KleisliFactory.eINSTANCE.createKleisliModel();
    kModel.setUri(getModelExtendedUri(containerModelEndpoint));
    kModel.setName(origModel.getName());
    kModel.setLevel(MIDLevel.INSTANCES);
    kModel.setDynamic(true);
    kModel.setSupertype(null);
    kModel.setMetatypeUri(origModel.getMetatypeUri());
    kModel.setOrigin(ModelOrigin.CREATED);
    kModel.setFileExtension(origModel.getFileExtension());
    containerModelEndpoint.setExtendedTarget(kModel);

    return kModel;
  }