Пример #1
0
  public boolean preValidationFullInsert() {
    boolean bResult = true;
    try {
      // check root
      dbSettings.Connect();
      QueryResults qr =
          dbSettings.QueryResults(
              SettingsQueryFactory.Q_CHECK_IF_ACTION_HAS_PARENT(
                  theAction.action_naming_convention()));
      dbSettings.EndConnect();
      String[] results = qr.getSingleColumnResult("THE_COUNT");
      if (results[0].equals("0")) {
        if (!ooDocument.hasSection("root")) {
          checkFieldsMessages.add("The document does not have a root section!");
          bResult = false;
          return bResult;
        }
      }

      if (ooDocument.hasSection(theAction.action_naming_convention())) {
        checkFieldsMessages.add(
            "The document already has a papers section, please delete the section first");
        bResult = false;
        return bResult;
      }

    } catch (Exception ex) {
      log.error("preValidation : " + ex.getMessage());
      bResult = false;
    } finally {
      return bResult;
    }
  }
 private toolbarAction get_parentAction() {
   Vector<Vector<String>> resultRows = new Vector<Vector<String>>();
   toolbarAction action = null;
   try {
     String currentDocumentType = BungeniEditorProperties.getEditorProperty("activeDocumentMode");
     dbSettings.Connect();
     QueryResults qr =
         dbSettings.QueryResults(
             SettingsQueryFactory.Q_FETCH_ACTION_BY_NAME(
                 currentDocumentType, this.m_subAction.parent_action_name()));
     dbSettings.EndConnect();
     if (qr == null) {
       throw new Exception("QueryResults returned null");
     }
     if (qr.hasResults()) {
       HashMap columns = qr.columnNameMap();
       // child actions are present
       // call the result nodes recursively...
       resultRows = qr.theResults();
       // should alwayrs return a single result
       Vector<java.lang.String> tableRow = new Vector<java.lang.String>();
       tableRow = resultRows.elementAt(0);
       action = new toolbarAction(tableRow, columns);
     }
   } catch (Exception ex) {
     log.error("getParentSection: " + ex.getMessage());
   } finally {
     return action;
   }
 }
Пример #3
0
  private void initData() {
    dbInstance.Connect();
    QueryResults qr =
        dbInstance.QueryResults(
            "select document_title, document_uri, document_date from tabled_documents");
    dbInstance.EndConnect();

    if (qr != null) {
      if (qr.hasResults()) {
        Vector<Vector<String>> resultRows = new Vector<Vector<String>>();
        resultRows = qr.theResults();

        DefaultTableModel mdl = new DefaultTableModel();
        mdl.setDataVector(resultRows, qr.getColumnsAsVector());
        tbl_tabledDocs.setModel(mdl);
      }
    }
  }
 private int check_containment_RootSection(String currentSectionname) {
   // check if the current section can have the root section as a parent
   String strQuery =
       "Select count(*) as THE_COUNT from ACTION_PARENT where ACTION_NAME='"
           + m_parentAction.action_name()
           + "'";
   dbSettings.Connect();
   QueryResults qr = dbSettings.QueryResults(strQuery);
   dbSettings.EndConnect();
   if (qr.hasResults()) {
     String[] theCount = qr.getSingleColumnResult("THE_COUNT");
     if (theCount[0].equals("0")) {
       // the section can have the root section as its container
       return BungeniError.VALID_SECTION_CONTAINER;
     } else {
       return BungeniError.INVALID_SECTION_CONTAINER;
     }
   } else {
     return BungeniError.INVALID_SECTION_CONTAINER;
   }
 }
  private int check_containment_Section(String currentContainerSection) {

    int error = BungeniError.GENERAL_ERROR;
    try {
      // get valid parent actions
      String strActionName = m_parentAction.action_name();
      dbSettings.Connect();
      String fetchParentQuery = SettingsQueryFactory.Q_FETCH_PARENT_ACTIONS(strActionName);
      log.debug("checkContainmentSection = " + fetchParentQuery);
      QueryResults qr = dbSettings.QueryResults(fetchParentQuery);
      dbSettings.EndConnect();
      String[] actionSectionTypes = qr.getSingleColumnResult("ACTION_SECTION_TYPE");
      // there can be multiple parents... so we iterate through the array if one of them is a valid
      // parent

      HashMap<String, String> sectionMetadata =
          ooDocument.getSectionMetadataAttributes(currentContainerSection);
      // if (sectionMetadata.get)
      String strDocSectionType = "";
      if (sectionMetadata.containsKey("BungeniSectionType")) {
        strDocSectionType = sectionMetadata.get("BungeniSectionType").trim();
        // check the doc section type against the array of valid action section types
        for (String sectionType : actionSectionTypes) {
          if (strDocSectionType.equals(sectionType.trim())) {
            error = BungeniError.VALID_SECTION_CONTAINER;
            break;
          } else {
            error = BungeniError.INVALID_SECTION_CONTAINER;
          }
        }
      } else {
        error = BungeniError.INVALID_SECTION_CONTAINER;
      }
    } catch (Exception ex) {
      log.error("check_containmentSection : " + ex.getMessage());
      log.error("check_containmentSection : " + CommonExceptionUtils.getStackTrace(ex));
    } finally {
      return error;
    }
  }