コード例 #1
0
  public void startElement(Properties ctx, Element element) throws SAXException {
    String elementValue = element.getElementValue();
    Attributes atts = element.attributes;
    log.info(elementValue + " " + atts.getValue("Name"));
    int id = 0;
    String entitytype = atts.getValue("EntityType");
    if (isProcessElement(ctx, entitytype)) {
      String value = atts.getValue("Value");

      // Get New process.
      id = get_IDWithColumn(ctx, "AD_Process", "Value", value);

      X_AD_Process m_Process = null;
      int AD_Backup_ID = -1;
      String Object_Status = null;
      if (id > 0) {
        m_Process = new X_AD_Process(ctx, id, getTrxName(ctx));
        AD_Backup_ID = copyRecord(ctx, "AD_Process", m_Process);
        Object_Status = "Update";
      } else {
        m_Process = new X_AD_Process(ctx, id, getTrxName(ctx));
        if (id <= 0
            && atts.getValue("AD_Process_ID") != null
            && Integer.parseInt(atts.getValue("AD_Process_ID")) <= PackOut.MAX_OFFICIAL_ID)
          m_Process.setAD_Process_ID(Integer.parseInt(atts.getValue("AD_Process_ID")));
        Object_Status = "New";
        AD_Backup_ID = 0;
      }

      String name = atts.getValue("Name");
      m_Process.setName(name);

      name = atts.getValue("ADWorkflowNameID");
      if (name != null && name.trim().length() > 0) {
        id = get_IDWithColumn(ctx, "AD_Workflow", "Name", name);
        if (id <= 0) {
          element.defer = true;
          element.unresolved = "AD_Workflow: " + name;
          return;
        }
        m_Process.setAD_Workflow_ID(id);
      }

      name = atts.getValue("ADPrintFormatNameID");
      if (name != null && name.trim().length() > 0) {
        id = get_IDWithColumn(ctx, "AD_PrintFormat", "Name", name);
        if (id <= 0) {
          if (element.pass == 1) {
            element.defer = true;
            element.unresolved = "AD_PrintFormat: " + name;
            return;
          } else {
            log.warning(
                "AD_PrintFormat: " + name + " not found for Process: " + m_Process.getName());
          }
        }
        if (id > 0) m_Process.setAD_PrintFormat_ID(id);
      }

      name = atts.getValue("ADReportViewNameID");
      if (name != null && name.trim().length() > 0) {
        id = get_IDWithColumn(ctx, "AD_ReportView", "Name", name);
        if (id <= 0) {
          if (element.pass == 1) {
            element.defer = true;
            element.unresolved = "AD_ReportView: " + name;
            return;
          } else {
            log.warning(
                "AD_ReportView: " + name + " not found for Process: " + m_Process.getName());
          }
        }
        if (id > 0) m_Process.setAD_ReportView_ID(id);
      }

      name = atts.getValue("ADFormNameID");
      if (name != null && name.trim().length() > 0) {
        id = get_IDWithColumn(ctx, "AD_Form", "Name", name);
        if (id <= 0) {
          element.defer = true;
          element.unresolved = "AD_Form: " + name;
          return;
        }
        m_Process.setAD_Form_ID(id);
      }

      name = atts.getValue("ADBrowseNameID");
      if (name != null && name.trim().length() > 0) {
        id = get_IDWithColumn(ctx, "AD_Browse", "Name", name);
        if (id <= 0) {
          element.defer = true;
          element.unresolved = "AD_Browse: " + name;
          return;
        }
        m_Process.setAD_Browse_ID(id);
      }

      m_Process.setAccessLevel(atts.getValue("AccessLevel"));
      m_Process.setClassname(getStringValue(atts, "Classname"));
      m_Process.setDescription(getStringValue(atts, "Description"));
      m_Process.setEntityType(atts.getValue("EntityType"));
      m_Process.setHelp(getStringValue(atts, "Help"));
      m_Process.setIsBetaFunctionality(
          Boolean.valueOf(atts.getValue("isBetaFunctionality")).booleanValue());
      m_Process.setIsDirectPrint(Boolean.valueOf(atts.getValue("isDirectPrint")).booleanValue());
      m_Process.setIsReport(Boolean.valueOf(atts.getValue("isReport")).booleanValue());
      m_Process.setName(atts.getValue("Name"));

      m_Process.setProcedureName(getStringValue(atts, "ProcedureName"));
      m_Process.setStatistic_Count(0);
      m_Process.setIsActive(
          atts.getValue("isActive") != null
              ? Boolean.valueOf(atts.getValue("isActive")).booleanValue()
              : true);
      m_Process.setStatistic_Seconds(0);
      m_Process.setValue(atts.getValue("Value"));
      m_Process.setWorkflowValue(atts.getValue("WorkflowValue"));
      m_Process.setShowHelp((getStringValue(atts, "ShowHelp")));
      m_Process.setJasperReport(getStringValue(atts, "JasperReport"));
      if (m_Process.save(getTrxName(ctx)) == true) {
        record_log(
            ctx,
            1,
            m_Process.getName(),
            "Process",
            m_Process.get_ID(),
            AD_Backup_ID,
            Object_Status,
            "AD_Process",
            get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Process"));
        element.recordId = m_Process.getAD_Process_ID();
      } else {
        record_log(
            ctx,
            0,
            m_Process.getName(),
            "Process",
            m_Process.get_ID(),
            AD_Backup_ID,
            Object_Status,
            "AD_Process",
            get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Process"));
        throw new POSaveFailedException("Process");
      }
    } else {
      element.skip = true;
    }
  }
コード例 #2
0
  public void startElement(Properties ctx, Element element) throws SAXException {
    String elementValue = element.getElementValue();
    int AD_Backup_ID = -1;
    String Object_Status = null;
    Attributes atts = element.attributes;
    log.info(elementValue + " " + atts.getValue("Name"));

    String name = atts.getValue("Name");
    int id = get_IDWithColumn(ctx, "AD_PrintFormat", "Name", name);
    X_AD_PrintFormat m_PrintFormat = new X_AD_PrintFormat(ctx, id, getTrxName(ctx));
    if (id <= 0
        && atts.getValue("AD_PrintFormat_ID") != null
        && Integer.parseInt(atts.getValue("AD_PrintFormat_ID")) <= PackOut.MAX_OFFICIAL_ID)
      m_PrintFormat.setAD_PrintFormat_ID(Integer.parseInt(atts.getValue("AD_PrintFormat_ID")));
    if (id > 0) {
      AD_Backup_ID = copyRecord(ctx, "AD_PrintFormat", m_PrintFormat);
      Object_Status = "Update";
    } else {
      Object_Status = "New";
      AD_Backup_ID = 0;
    }

    name = atts.getValue("ADReportviewnameID");
    if (name != null && name.trim().length() > 0) {
      id = get_IDWithColumn(ctx, "AD_ReportView", "Name", name);
      if (id <= 0) {
        element.defer = true;
        return;
      }
      m_PrintFormat.setAD_ReportView_ID(id);
    }

    name = atts.getValue("ADTableNameID");
    id = get_IDWithColumn(ctx, "AD_Table", "TableName", name);
    if (id == 0) {
      MTable m_Table = new MTable(ctx, 0, getTrxName(ctx));
      m_Table.setAccessLevel("3");
      m_Table.setName(name);
      m_Table.setTableName(name);
      if (m_Table.save(getTrxName(ctx)) == true) {
        record_log(
            ctx,
            1,
            m_Table.getName(),
            "Table",
            m_Table.get_ID(),
            0,
            "New",
            "AD_Table",
            get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Table"));
      } else {
        record_log(
            ctx,
            0,
            m_Table.getName(),
            "Table",
            m_Table.get_ID(),
            0,
            "New",
            "AD_Table",
            get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Table"));
      }
      id = get_IDWithColumn(ctx, "AD_Table", "TableName", name);
    }
    m_PrintFormat.setAD_Table_ID(id);

    name = atts.getValue("ADPrintTableFormatID");
    if (name != null && name.trim().length() > 0) {
      id = get_IDWithColumn(ctx, "AD_PrintTableFormat", "Name", name);
      if (id <= 0) {
        element.defer = true;
        return;
      }
      m_PrintFormat.setAD_PrintTableFormat_ID(id);
    }

    name = atts.getValue("ADPrintColorID");
    if (name != null && name.trim().length() > 0) {
      id = get_IDWithColumn(ctx, "AD_PrintColor", "Name", name);
      if (id <= 0) {
        element.defer = true;
        return;
      }
      m_PrintFormat.setAD_PrintColor_ID(id);
    }

    name = atts.getValue("ADPrintFontID");
    if (name != null && name.trim().length() > 0) {
      id = get_IDWithColumn(ctx, "AD_PrintFont", "Name", name);
      if (id <= 0) {
        element.defer = true;
        return;
      }
      m_PrintFormat.setAD_PrintFont_ID(id);
    }

    name = atts.getValue("ADPrintPaperID");
    if (name != null && name.trim().length() > 0) {
      id = get_IDWithColumn(ctx, "AD_PrintPaper", "Name", name);
      if (id <= 0) {
        element.defer = true;
        return;
      }
      m_PrintFormat.setAD_PrintPaper_ID(id);
    }

    m_PrintFormat.setDescription(getStringValue(atts, "Description"));
    m_PrintFormat.setName(atts.getValue("Name"));
    m_PrintFormat.setPrinterName(getStringValue(atts, "PrinterName"));
    m_PrintFormat.setFooterMargin(Integer.parseInt(atts.getValue("FooterMargin")));

    m_PrintFormat.setHeaderMargin(Integer.parseInt(atts.getValue("HeaderMargin")));
    m_PrintFormat.setCreateCopy(atts.getValue("CreateCopy"));
    m_PrintFormat.setIsActive(
        atts.getValue("isActive") != null
            ? Boolean.valueOf(atts.getValue("isActive")).booleanValue()
            : true);

    m_PrintFormat.setIsTableBased(Boolean.valueOf(atts.getValue("isTableBased")).booleanValue());
    m_PrintFormat.setIsForm(Boolean.valueOf(atts.getValue("isForm")).booleanValue());
    m_PrintFormat.setIsStandardHeaderFooter(
        Boolean.valueOf(atts.getValue("isStandardHeader")).booleanValue());

    m_PrintFormat.setIsDefault(Boolean.valueOf(atts.getValue("isDefault")).booleanValue());
    if (m_PrintFormat.save(getTrxName(ctx)) == true) {
      record_log(
          ctx,
          1,
          m_PrintFormat.getName(),
          "PrintFormat",
          m_PrintFormat.get_ID(),
          AD_Backup_ID,
          Object_Status,
          "AD_PrintFormat",
          get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_PrintFormat"));
      element.recordId = m_PrintFormat.getAD_PrintFormat_ID();
    } else {
      record_log(
          ctx,
          0,
          m_PrintFormat.getName(),
          "PrintFormat",
          m_PrintFormat.get_ID(),
          AD_Backup_ID,
          Object_Status,
          "AD_PrintFormat",
          get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_PrintFormat"));
      throw new POSaveFailedException("Failed to save Print Format");
    }
  }
コード例 #3
0
  public void startElement(Properties ctx, Element element) throws SAXException {
    PackIn packIn = (PackIn) ctx.get("PackInProcess");
    String elementValue = element.getElementValue();
    Attributes atts = element.attributes;
    log.info(elementValue + " " + atts.getValue("ColumnName"));
    int success = 0;
    String entitytype = atts.getValue("EntityType");
    if (isProcessElement(ctx, entitytype)) {
      if (element.parent != null
          && element.parent.getElementValue().equals("table")
          && element.parent.defer) {
        element.defer = true;
        return;
      }
      String columnName = atts.getValue("ColumnName");
      String tableName = atts.getValue("ADTableNameID");
      int tableid = 0;
      if (element.parent != null
          && element.parent.getElementValue().equals("table")
          && element.parent.recordId > 0) {
        tableid = element.parent.recordId;
      } else {
        tableid = packIn.getTableId(tableName);
      }
      if (tableid <= 0) {
        tableid = get_IDWithColumn(ctx, "AD_Table", "TableName", tableName);
        if (tableid > 0) packIn.addTable(tableName, tableid);
      }
      int id = packIn.getColumnId(tableName, columnName);
      if (id <= 0) {
        id =
            get_IDWithMasterAndColumn(
                ctx, "AD_Column", "ColumnName", columnName, "AD_Table", tableid);
        if (id > 0) {
          packIn.addColumn(tableName, columnName, id);
        }
      }
      MColumn m_Column = new MColumn(ctx, id, getTrxName(ctx));
      if (id <= 0
          && atts.getValue("AD_Column_ID") != null
          && Integer.parseInt(atts.getValue("AD_Column_ID")) <= PackOut.MAX_OFFICIAL_ID)
        m_Column.setAD_Column_ID(Integer.parseInt(atts.getValue("AD_Column_ID")));
      int AD_Backup_ID = -1;
      String Object_Status = null;
      if (id > 0) {
        AD_Backup_ID = copyRecord(ctx, "AD_Column", m_Column);
        Object_Status = "Update";
      } else {
        Object_Status = "New";
        AD_Backup_ID = 0;
      }
      m_Column.setColumnName(columnName);

      // Process
      String processName = atts.getValue("ADProcessNameID");
      int AD_Process_ID = get_IDWithColumn(ctx, "AD_Process", "Value", processName);
      if (AD_Process_ID <= 0
      /** TODO PackOut version check 005 */
      ) {
        AD_Process_ID = get_IDWithColumn(ctx, "AD_Process", "Name", processName);
      }
      m_Column.setAD_Process_ID(AD_Process_ID);
      //
      String Name = atts.getValue("ADReferenceNameID");
      id = get_IDWithColumn(ctx, "AD_Reference", "Name", Name);
      m_Column.setAD_Reference_ID(id);
      // log.info("Column ID ->"+id);
      Name = atts.getValue("ADTableNameID");
      id = get_IDWithColumn(ctx, "AD_Table", "TableName", Name);
      m_Column.setAD_Table_ID(id);

      Name = atts.getValue("ADValRuleNameID");
      id = get_IDWithColumn(ctx, "AD_Val_Rule", "Name", Name);
      m_Column.setAD_Val_Rule_ID(id);
      Name = atts.getValue("ADReferenceNameValueID");
      id = get_IDWithColumn(ctx, "AD_Reference", "Name", Name);
      m_Column.setAD_Reference_Value_ID(id);
      m_Column.setCallout(getStringValue(atts, "Callout"));
      m_Column.setColumnSQL(getStringValue(atts, "ColumnSQL"));

      m_Column.setColumnName(atts.getValue("ColumnName"));
      m_Column.setDefaultValue(getStringValue(atts, "DefaultValue"));
      m_Column.setDescription(getStringValue(atts, "Description"));
      m_Column.setEntityType(atts.getValue("EntityType"));

      if (Integer.parseInt(atts.getValue("FieldLength")) > 0)
        m_Column.setFieldLength(Integer.parseInt(atts.getValue("FieldLength")));
      m_Column.setHelp(getStringValue(atts, "Help"));
      m_Column.setIsActive(
          atts.getValue("isActive") != null
              ? Boolean.valueOf(atts.getValue("isActive")).booleanValue()
              : true);
      m_Column.setIsAlwaysUpdateable(
          (Boolean.valueOf(atts.getValue("isAlwaysUpdateable")).booleanValue()));
      // m_Column.setIsEncrypted(atts.getValue("isEncrypted"));
      m_Column.setIsIdentifier((Boolean.valueOf(atts.getValue("isIdentifier")).booleanValue()));
      m_Column.setIsKey((Boolean.valueOf(atts.getValue("isKey")).booleanValue()));
      m_Column.setIsMandatory((Boolean.valueOf(atts.getValue("isMandatory")).booleanValue()));

      m_Column.setIsParent((Boolean.valueOf(atts.getValue("isParent")).booleanValue()));
      m_Column.setIsSelectionColumn(
          (Boolean.valueOf(atts.getValue("isSelectionColumn")).booleanValue()));
      m_Column.setIsSyncDatabase(atts.getValue("getIsSyncDatabase"));

      m_Column.setIsTranslated((Boolean.valueOf(atts.getValue("isTranslated")).booleanValue()));
      m_Column.setIsUpdateable((Boolean.valueOf(atts.getValue("isUpdateable")).booleanValue()));
      m_Column.setName(atts.getValue("Name"));
      m_Column.setReadOnlyLogic(getStringValue(atts, "ReadOnlyLogic"));

      if (Integer.parseInt(atts.getValue("SeqNo")) > 0)
        m_Column.setSeqNo(Integer.parseInt(atts.getValue("SeqNo")));
      m_Column.setVFormat(getStringValue(atts, "VFormat"));
      if (getStringValue(atts, "ValueMax") != null) m_Column.setValueMax(atts.getValue("ValueMax"));
      if (getStringValue(atts, "ValueMin") != null) m_Column.setValueMin(atts.getValue("ValueMin"));
      if (getStringValue(atts, "Version") != null)
        m_Column.setVersion(new BigDecimal(atts.getValue("Version")));

      m_Column.setInfoFactoryClass(getStringValue(atts, "InfoFactoryClass"));

      // Setup Element.
      id = get_IDWithColumn(ctx, "AD_Element", "ColumnName", m_Column.getColumnName());
      X_AD_Element adElement = new X_AD_Element(ctx, id, getTrxName(ctx));

      String Object_Status_col = Object_Status;
      if (adElement.getAD_Element_ID() == 0) {
        // Object_Status = "New";
        adElement.setColumnName(m_Column.getColumnName());
        adElement.setEntityType(m_Column.getEntityType());
        adElement.setPrintName(m_Column.getColumnName());

        adElement.setName(m_Column.getColumnName());
        if (adElement.save(getTrxName(ctx)) == true) {
          record_log(
              ctx,
              1,
              m_Column.getName(),
              "Element",
              adElement.getAD_Element_ID(),
              AD_Backup_ID,
              "New",
              "AD_Element",
              get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Element"));
        } else {
          record_log(
              ctx,
              0,
              m_Column.getName(),
              "Element",
              adElement.getAD_Element_ID(),
              AD_Backup_ID,
              "New",
              "AD_Element",
              get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Element"));
        }
      }

      Object_Status = Object_Status_col;
      m_Column.setAD_Element_ID(adElement.getAD_Element_ID());

      boolean recreateColumn =
          (m_Column.is_new()
              || m_Column.is_ValueChanged("AD_Reference_ID")
              || m_Column.is_ValueChanged("FieldLength")
              || m_Column.is_ValueChanged("ColumnName")
              || m_Column.is_ValueChanged("IsMandatory"));

      // ignore fieldlength change for clob and lob
      if (!m_Column.is_ValueChanged("AD_Reference_ID") && m_Column.is_ValueChanged("FieldLength")) {
        if (DisplayType.isLOB(m_Column.getAD_Reference_ID())) {
          recreateColumn = false;
        }
      }

      // changed default ??
      // m_Column.is_ValueChanged("DefaultValue") doesn't work well with
      // nulls
      if (!recreateColumn) {
        String oldDefault = (String) m_Column.get_ValueOld("DefaultValue");
        String newDefault = m_Column.getDefaultValue();
        if (oldDefault != null && oldDefault.length() == 0) oldDefault = null;
        if (newDefault != null && newDefault.length() == 0) newDefault = null;
        if ((oldDefault == null && newDefault != null)
            || (oldDefault != null && newDefault == null)) {
          recreateColumn = true;
        } else if (oldDefault != null && newDefault != null) {
          if (!oldDefault.equals(newDefault)) recreateColumn = true;
        }
      }

      // Don't create database column for virtual columns
      boolean syncDatabase = "Y".equalsIgnoreCase(atts.getValue("getIsSyncDatabase"));
      if (recreateColumn) {
        if (m_Column.isVirtualColumn() || !syncDatabase) recreateColumn = false;
      }

      if (m_Column.save(getTrxName(ctx)) == true) {
        record_log(
            ctx,
            1,
            m_Column.getName(),
            "Column",
            m_Column.get_ID(),
            AD_Backup_ID,
            Object_Status,
            "AD_Column",
            get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Column"));
        element.recordId = m_Column.getAD_Column_ID();
      } else {
        record_log(
            ctx,
            0,
            m_Column.getName(),
            "Column",
            m_Column.get_ID(),
            AD_Backup_ID,
            Object_Status,
            "AD_Column",
            get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Column"));
        throw new POSaveFailedException("Failed to import column.");
      }

      if (recreateColumn || syncDatabase) {
        MTable table = new MTable(ctx, m_Column.getAD_Table_ID(), getTrxName(ctx));
        if (!table.isView() && !m_Column.isVirtualColumn()) {
          success = createColumn(ctx, table, m_Column, recreateColumn);

          if (success == 1) {
            record_log(
                ctx,
                1,
                m_Column.getColumnName(),
                "dbColumn",
                m_Column.get_ID(),
                0,
                Object_Status,
                atts.getValue("ADTableNameID").toUpperCase(),
                get_IDWithColumn(
                    ctx, "AD_Table", "TableName", atts.getValue("ADTableNameID").toUpperCase()));
          } else {
            record_log(
                ctx,
                0,
                m_Column.getColumnName(),
                "dbColumn",
                m_Column.get_ID(),
                0,
                Object_Status,
                atts.getValue("ADTableNameID").toUpperCase(),
                get_IDWithColumn(
                    ctx, "AD_Table", "TableName", atts.getValue("ADTableNameID").toUpperCase()));
            throw new DatabaseAccessException(
                "Failed to create column or related constraint for " + m_Column.getColumnName());
          }
        }
      }
    } else {
      element.skip = true;
    }
  }