示例#1
0
  @NotNull
  @Override
  public SModel create(DataSource dataSource, @NotNull Map<String, String> options)
      throws IOException {
    if (!(dataSource instanceof StreamDataSource)) {
      throw new UnsupportedDataSourceException(dataSource);
    }

    StreamDataSource source = (StreamDataSource) dataSource;
    String modelName = options.get(OPTION_MODELNAME);
    if (modelName == null) {
      throw new IOException("modelName is not provided");
    }
    String modulRef = options.get(OPTION_MODULEREF);
    if (modulRef == null) {
      throw new IOException("moduleRef is not provided");
    }

    final SModelHeader header = new SModelHeader();
    header.setModelReference(
        PersistenceFacade.getInstance()
            .createModelReference(null, jetbrains.mps.smodel.SModelId.generate(), modelName));
    return new DefaultSModelDescriptor(new PersistenceFacility(this, source), header);
  }