Esempio n. 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)));
  }
Esempio n. 2
0
  /**
   * 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)));
    }
  }
Esempio n. 3
0
  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;
  }