Exemple #1
0
  /**
   * Constructor for use when serializing.
   *
   * @param baseUri the base uri of the REST request
   * @param mask the mask
   * @param uow the transaction
   * @throws KException if error occurs
   */
  public RestVdbMask(URI baseUri, Mask mask, UnitOfWork uow) throws KException {
    super(baseUri, mask, uow);

    setName(mask.getName(uow));
    setOrder(mask.getOrder(uow));

    Permission permission = ancestor(mask, Permission.class, uow);
    ArgCheck.isNotNull(permission);
    String permName = permission.getName(uow);

    DataRole dataRole = ancestor(permission, DataRole.class, uow);
    ArgCheck.isNotNull(dataRole);
    String dataRoleName = dataRole.getName(uow);

    Vdb vdb = ancestor(dataRole, Vdb.class, uow);
    ArgCheck.isNotNull(vdb);
    String vdbName = vdb.getName(uow);

    Properties settings = getUriBuilder().createSettings(SettingNames.VDB_NAME, vdbName);
    getUriBuilder().addSetting(settings, SettingNames.DATA_ROLE_ID, dataRoleName);
    getUriBuilder().addSetting(settings, SettingNames.PERMISSION_ID, permName);
    getUriBuilder()
        .addSetting(settings, SettingNames.PERMISSION_CHILD_TYPE, LinkType.MASKS.uriName());
    getUriBuilder().addSetting(settings, SettingNames.PERMISSION_CHILD_ID, getId());

    addLink(
        new RestLink(
            LinkType.SELF, getUriBuilder().buildVdbPermissionChildUri(LinkType.SELF, settings)));
    addLink(
        new RestLink(
            LinkType.PARENT,
            getUriBuilder().buildVdbPermissionChildUri(LinkType.PARENT, settings)));
  }
  /**
   * Constructor for use when serializing.
   *
   * @param baseUri the base uri of the REST request
   * @param source the source
   * @param uow the transaction
   * @throws KException if error occurs
   */
  public RestVdbModelSource(URI baseUri, ModelSource source, UnitOfWork uow) throws KException {
    super(baseUri, source, uow);

    setJndiName(source.getJndiName(uow));
    String translatorName = source.getTranslatorName(uow);
    setTranslator(translatorName);

    Model model = ancestor(source, Model.class, uow);
    ArgCheck.isNotNull(model);
    String modelName = model.getName(uow);

    Vdb vdb = ancestor(model, Vdb.class, uow);
    ArgCheck.isNotNull(vdb);
    String vdbName = vdb.getName(uow);

    Properties settings = getUriBuilder().createSettings(SettingNames.VDB_NAME, vdbName);
    getUriBuilder().addSetting(settings, SettingNames.MODEL_NAME, modelName);
    getUriBuilder().addSetting(settings, SettingNames.SOURCE_NAME, getId());

    addLink(
        new RestLink(
            LinkType.SELF, getUriBuilder().buildVdbModelSourceUri(LinkType.SELF, settings)));
    addLink(
        new RestLink(
            LinkType.PARENT, getUriBuilder().buildVdbModelSourceUri(LinkType.PARENT, settings)));

    Translator[] translators = vdb.getTranslators(uow, translatorName);
    if (translators != null && translators.length == 1) {
      getUriBuilder().addSetting(settings, SettingNames.TRANSLATOR_NAME, translatorName);
      addLink(
          new RestLink(
              LinkType.REFERENCE,
              getUriBuilder().buildVdbModelSourceUri(LinkType.REFERENCE, settings)));
    }
  }
 protected Table createTable(
     final String vdbName, final String vdbPath, final String modelName, final String tableName)
     throws Exception {
   final WorkspaceManager mgr = WorkspaceManager.getInstance(_repo);
   final Vdb vdb = mgr.createVdb(this.uow, null, vdbName, vdbPath);
   final Model model = vdb.addModel(this.uow, modelName);
   return model.addTable(this.uow, tableName);
 }
  protected Model createModel(final String vdbName, final String vdbPath, final String modelName)
      throws Exception {
    final WorkspaceManager mgr = WorkspaceManager.getInstance(_repo);
    final Vdb vdb = mgr.createVdb(this.uow, null, vdbName, vdbPath);
    final Model model = vdb.addModel(this.uow, modelName);

    assertThat(model.getPrimaryType(this.uow).getName(), is(VdbLexicon.Vdb.DECLARATIVE_MODEL));
    assertThat(model.getName(this.uow), is(modelName));
    return model;
  }
  protected Vdb createVdb(
      final String vdbName, final KomodoObject parent, final String originalFilePath)
      throws Exception {
    final WorkspaceManager mgr = WorkspaceManager.getInstance(_repo);
    final Vdb vdb = mgr.createVdb(this.uow, parent, vdbName, originalFilePath);

    assertThat(vdb.getPrimaryType(this.uow).getName(), is(VdbLexicon.Vdb.VIRTUAL_DATABASE));
    assertThat(vdb.getName(this.uow), is(vdbName));
    assertThat(vdb.getOriginalFilePath(this.uow), is(originalFilePath));
    return vdb;
  }
  @Before
  public void init() throws Exception {
    final Vdb vdb = createVdb();
    final Model model = createModel();
    this.parentTable = model.addTable(getTransaction(), "parentTable");

    final Model refModel = vdb.addModel(getTransaction(), "refModel");
    this.refTable = refModel.addTable(getTransaction(), "refTable");

    this.foreignKey = this.parentTable.addForeignKey(getTransaction(), NAME, this.refTable);
    commit();
  }