예제 #1
0
파일: MappingMeta.java 프로젝트: cnopens/BA
  public void saveRep(Repository rep, ObjectId id_transformation, ObjectId id_step)
      throws KettleException {
    rep.saveStepAttribute(
        id_transformation,
        id_step,
        "specification_method",
        specificationMethod == null ? null : specificationMethod.getCode());
    rep.saveStepAttribute(
        id_transformation,
        id_step,
        "trans_object_id",
        transObjectId == null ? null : transObjectId.toString());
    rep.saveStepAttribute(id_transformation, id_step, "filename", fileName); // $NON-NLS-1$
    rep.saveStepAttribute(id_transformation, id_step, "trans_name", transName); // $NON-NLS-1$
    rep.saveStepAttribute(
        id_transformation, id_step, "directory_path", directoryPath); // $NON-NLS-1$

    for (int i = 0; i < inputMappings.size(); i++) {
      inputMappings.get(i).saveRep(rep, id_transformation, id_step, "input_", i);
    }

    for (int i = 0; i < outputMappings.size(); i++) {
      outputMappings.get(i).saveRep(rep, id_transformation, id_step, "output_", i);
    }

    // save the mapping parameters too
    //
    mappingParameters.saveRep(rep, id_transformation, id_step);

    rep.saveStepAttribute(
        id_transformation, id_step, 0, "allow_multiple_input", allowingMultipleInputs);
    rep.saveStepAttribute(
        id_transformation, id_step, 0, "allow_multiple_output", allowingMultipleOutputs);
  }
예제 #2
0
파일: MappingMeta.java 프로젝트: cnopens/BA
  public String getXML() {
    StringBuffer retval = new StringBuffer(300);

    retval
        .append("    ")
        .append(
            XMLHandler.addTagValue(
                "specification_method",
                specificationMethod == null ? null : specificationMethod.getCode()));
    retval
        .append("    ")
        .append(
            XMLHandler.addTagValue(
                "trans_object_id", transObjectId == null ? null : transObjectId.toString()));
    // Export a little bit of extra information regarding the reference since it doesn't really
    // matter outside the same repository.
    //
    if (repository != null && transObjectId != null) {
      try {
        RepositoryObject objectInformation =
            repository.getObjectInformation(transObjectId, RepositoryObjectType.TRANSFORMATION);
        if (objectInformation != null) {
          transName = objectInformation.getName();
          directoryPath = objectInformation.getRepositoryDirectory().getPath();
        }
      } catch (KettleException e) {
        // Ignore object reference problems.  It simply means that the reference is no longer valid.
      }
    }
    retval.append("    ").append(XMLHandler.addTagValue("trans_name", transName)); // $NON-NLS-1$
    retval.append("    ").append(XMLHandler.addTagValue("filename", fileName)); // $NON-NLS-1$
    retval
        .append("    ")
        .append(XMLHandler.addTagValue("directory_path", directoryPath)); // $NON-NLS-1$

    retval
        .append("    ")
        .append(XMLHandler.openTag("mappings"))
        .append(Const.CR); // $NON-NLS-1$ $NON-NLS-2$

    retval
        .append("      ")
        .append(XMLHandler.openTag("input"))
        .append(Const.CR); // $NON-NLS-1$ $NON-NLS-2$
    for (int i = 0; i < inputMappings.size(); i++) {
      retval.append(inputMappings.get(i).getXML());
    }
    retval
        .append("      ")
        .append(XMLHandler.closeTag("input"))
        .append(Const.CR); // $NON-NLS-1$ $NON-NLS-2$

    retval
        .append("      ")
        .append(XMLHandler.openTag("output"))
        .append(Const.CR); // $NON-NLS-1$ $NON-NLS-2$
    for (int i = 0; i < outputMappings.size(); i++) {
      retval.append(outputMappings.get(i).getXML());
    }
    retval
        .append("      ")
        .append(XMLHandler.closeTag("output"))
        .append(Const.CR); // $NON-NLS-1$ $NON-NLS-2$

    // Add the mapping parameters too
    //
    retval.append("      ").append(mappingParameters.getXML()).append(Const.CR); // $NON-NLS-1$

    retval
        .append("    ")
        .append(XMLHandler.closeTag("mappings"))
        .append(Const.CR); // $NON-NLS-1$ $NON-NLS-2$

    retval
        .append("    ")
        .append(
            XMLHandler.addTagValue("allow_multiple_input", allowingMultipleInputs)); // $NON-NLS-1$
    retval
        .append("    ")
        .append(
            XMLHandler.addTagValue(
                "allow_multiple_output", allowingMultipleOutputs)); // $NON-NLS-1$

    return retval.toString();
  }
  public void editConnection() {
    try {
      Collection<UIDatabaseConnection> connections = connectionsTable.getSelectedItems();

      if (connections != null && !connections.isEmpty()) {
        // Grab the first item in the list & send it to the database dialog
        DatabaseMeta databaseMeta =
            ((UIDatabaseConnection) connections.toArray()[0]).getDatabaseMeta();

        // Make sure this connection already exists and store its id for updating
        ObjectId idDatabase = repository.getDatabaseID(databaseMeta.getName());
        if (idDatabase == null) {
          MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
          mb.setMessage(
              BaseMessages.getString(
                  PKG, "RepositoryExplorerDialog.Connection.Edit.DoesNotExists.Message"));
          mb.setText(
              BaseMessages.getString(
                  PKG, "RepositoryExplorerDialog.Connection.Edit.DoesNotExists.Title"));
          mb.open();
        } else {
          getDatabaseDialog().setDatabaseMeta(databaseMeta);
          String dbName = getDatabaseDialog().open();
          if (dbName != null) {
            dbName = dbName.trim();
            if (!dbName.isEmpty()) {
              ObjectId idRenamed = repository.getDatabaseID(dbName);
              if (idRenamed == null || idRenamed.equals(idDatabase)) {
                // renaming to non-existing name or updating the current
                repository.insertLogEntry(
                    BaseMessages.getString(
                        PKG,
                        "ConnectionsController.Message.UpdatingDatabase",
                        databaseMeta.getName()));
                repository.save(databaseMeta, Const.VERSION_COMMENT_EDIT_VERSION, null);
              } else {
                // trying to rename to an existing name - show error dialog
                showAlreadyExistsMessage();
              }
            }
          }
          // We should be able to tell the difference between a cancel and an empty database name
          //
          // else {
          // MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
          // mb.setMessage(BaseMessages.getString(PKG,
          // "RepositoryExplorerDialog.Connection.Edit.MissingName.Message"));
          // mb.setText(BaseMessages.getString(PKG,
          // "RepositoryExplorerDialog.Connection.Edit.MissingName.Title"));
          // mb.open();
          // }
        }
      } else {
        MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
        mb.setMessage(
            BaseMessages.getString(
                PKG, "RepositoryExplorerDialog.Connection.Edit.NoItemSelected.Message"));
        mb.setText(
            BaseMessages.getString(
                PKG, "RepositoryExplorerDialog.Connection.Edit.NoItemSelected.Title"));
        mb.open();
      }
    } catch (KettleException e) {
      if (mainController == null || !mainController.handleLostRepository(e)) {
        new ErrorDialog(
            shell,
            BaseMessages.getString(
                PKG, "RepositoryExplorerDialog.Connection.Create.UnexpectedError.Title"),
            BaseMessages.getString(
                PKG, "RepositoryExplorerDialog.Connection.Edit.UnexpectedError.Message"),
            e);
      }
    } finally {
      refreshConnectionList();
    }
  }