Package com.commander4j.db

Examples of com.commander4j.db.JDBMaterial


    }

  }

  private void populateList() {
    JDBMaterial material = new JDBMaterial(Common.selectedHostID, Common.sessionID);

    JDBMaterialTableModel materialtable = new JDBMaterialTableModel(material.getMaterialDataResultSet(listStatement));
    TableRowSorter<JDBMaterialTableModel> sorter = new TableRowSorter<JDBMaterialTableModel>(materialtable);

    jTable1.setRowSorter(sorter);
    jTable1.setModel(materialtable);
View Full Code Here


      }
      jButtonUpdate.setEnabled(false);
    }
    else
    {
      JDBMaterial mat = new JDBMaterial(Common.selectedHostID, Common.sessionID);
      mat.getMaterialProperties(material);
      jComboBoxStatus.setSelectedItem(mat.getDefaultBatchStatus());

      Date de = JUtility.getSQLDateTime();
      try
      {
        dateTimePicker.setDate(mat.calcBBE(de, mat.getShelfLife(), mat.getShelfLifeUom(), mat.getShelfLifeRule()));
      }
      catch (Exception e)
      {

      }
View Full Code Here

  public Boolean processMessage(GenericMessageHeader gmh)
  {
    Boolean result = true;

    JDBMaterial mat = new JDBMaterial(getHostID(), getSessionID());
    JDBMaterialType mattype = new JDBMaterialType(getHostID(), getSessionID());
    JDBMaterialLocation matlocn = new JDBMaterialLocation(getHostID(), getSessionID());
    JDBLocation locn = new JDBLocation(getHostID(), getSessionID());
    JDBMaterialUom matuom = new JDBMaterialUom(getHostID(), getSessionID());
    JDBUom uomdb = new JDBUom(getHostID(), getSessionID());
    JDBInterface inter = new JDBInterface(getHostID(), getSessionID());
    JDBControl ctrl = new JDBControl(getHostID(), getSessionID());

    String defaultBatchStatus = ctrl.getKeyValue("DEFAULT BATCH STATUS");

    inter.getInterfaceProperties("Material Definition", "Input");

    material = JUtility.replaceNullStringwithBlank(gmh.getXMLDocument().findXPath("//message/messageData/materialDefinition/material").trim());
    setErrorMessage("Material " + material + " updated.");
    materialType = JUtility.replaceNullStringwithBlank(gmh.getXMLDocument().findXPath("//message/messageData/materialDefinition/materialType").trim());
   
    if (mattype.isValidMaterialType(materialType)==false)
    {
      mattype.create(materialType, materialType);
    }
   
    description = JUtility.replaceNullStringwithBlank(gmh.getXMLDocument().findXPath("//message/messageData/materialDefinition/description").trim());
    base_uom = JUtility.replaceNullStringwithBlank(gmh.getXMLDocument().findXPath("//message/messageData/materialDefinition/base_uom").trim());
    base_uom = uomdb.convertUom(inter.getUOMConversion(), base_uom);

    production_uom = JUtility.replaceNullStringwithBlank(gmh.getXMLDocument().findXPath("//message/messageData/materialDefinition/production_uom").trim());
    production_uom = uomdb.convertUom(inter.getUOMConversion(), production_uom);

    issue_uom = JUtility.replaceNullStringwithBlank(gmh.getXMLDocument().findXPath("//message/messageData/materialDefinition/issue_uom").trim());
    issue_uom = uomdb.convertUom(inter.getUOMConversion(), issue_uom);

    shelf_life_uom = JUtility.replaceNullStringwithBlank(gmh.getXMLDocument().findXPath("//message/messageData/materialDefinition/shelf_life_uom").trim());
    equipment_type = JUtility.replaceNullStringwithBlank(gmh.getXMLDocument().findXPath("//message/messageData/materialDefinition/equipment_Type").trim());
    shelf_life = JUtility.replaceNullStringwithBlank(gmh.getXMLDocument().findXPath("//message/messageData/materialDefinition/shelf_life").trim());
    shelf_life_rule = JUtility.replaceNullStringwithBlank(gmh.getXMLDocument().findXPath("//message/messageData/materialDefinition/shelf_life_rule").trim());
    gross_weight = JUtility.replaceNullStringwithBlank(gmh.getXMLDocument().findXPath("//message/messageData/materialDefinition/gross_weight").trim());
    net_weight = JUtility.replaceNullStringwithBlank(gmh.getXMLDocument().findXPath("//message/messageData/materialDefinition/net_weight").trim());

    weight_uom = JUtility.replaceNullStringwithBlank(gmh.getXMLDocument().findXPath("//message/messageData/materialDefinition/weight_uom").trim());
    weight_uom = uomdb.convertUom(inter.getUOMConversion(), weight_uom);

    old_material = JUtility.replaceNullStringwithBlank(gmh.getXMLDocument().findXPath("//message/messageData/materialDefinition/old_material").trim());
    inspection_id = JUtility.replaceNullStringwithBlank(gmh.getXMLDocument().findXPath("//message/messageData/materialDefinition/inspection_id").trim());
    default_batch_status = JUtility.replaceNullStringwithBlank(gmh.getXMLDocument().findXPath("//message/messageData/materialDefinition/default_batch_status").trim());
   
   
    repeat = true;
    seq = 1;

    do
    {
      key = "//message/messageData/materialDefinition/validLocations/location[" + String.valueOf(seq) + "]/id";
      location = JUtility.replaceNullStringwithBlank(gmh.getXMLDocument().findXPath(key).trim());
      key = "//message/messageData/materialDefinition/validLocations/location[" + String.valueOf(seq) + "]/status";
      status = JUtility.replaceNullStringwithBlank(gmh.getXMLDocument().findXPath(key).trim());
     
      if (location.length() > 0)
      {
        if (locn.isValidLocation(location)==true)
        {
          if (matlocn.isValidMaterialLocation(material,location)==false)
          {
            matlocn.create(material, location);
          }
          matlocn.setStatus(status);
          matlocn.update();
        }
     
      } else
      {
        repeat = false;
      }
      seq++;
     
    } while (repeat);

    repeat = true;
    seq = 1;
    String matUOMError = "";
   
    do
    {
      key = "//message/messageData/materialDefinition/materialUOMDefinition[" + String.valueOf(seq) + "]/uom";
      uom = JUtility.replaceNullStringwithBlank(gmh.getXMLDocument().findXPath(key).trim());
      uom = uomdb.convertUom(inter.getUOMConversion(), uom);

      if (uom.length() > 0)
      {

        key = "//message/messageData/materialDefinition/materialUOMDefinition[" + String.valueOf(seq) + "]/numerator";
        numerator = JUtility.replaceNullStringwithBlank(gmh.getXMLDocument().findXPath(key).trim());

        key = "//message/messageData/materialDefinition/materialUOMDefinition[" + String.valueOf(seq) + "]/denominator";
        denominator = JUtility.replaceNullStringwithBlank(gmh.getXMLDocument().findXPath(key).trim());

        key = "//message/messageData/materialDefinition/materialUOMDefinition[" + String.valueOf(seq) + "]/ean";
        ean = gmh.getXMLDocument().findXPath(key).trim();

        key = "//message/messageData/materialDefinition/materialUOMDefinition[" + String.valueOf(seq) + "]/variant";
        variant = gmh.getXMLDocument().findXPath(key).trim();

        if (uomdb.isValidInternalUom(uom)==false)
        {
          uomdb.create(uom, uom, uom, "Auto created UOM");
        }
       
        if (matuom.getMaterialUomProperties(material, uom) == false)
        {
          matuom.setMaterial(material);
          matuom.setUom(uom);
          if (matuom.create() == false)
          {
            result = false;
            matUOMError = "Material " + material + " UOM [" + uom + "] create error. " + matuom.getErrorMessage();
            setErrorMessage(matUOMError);
          } else
          {
            setErrorMessage("Material " + material + " created.");
          }
        }

        try
        {
          matuom.setNumerator(Integer.valueOf(JUtility.getDefaultValue(numerator, String.valueOf(matuom.getNumerator()), "0")));
          matuom.setDenominator(Integer.valueOf(JUtility.getDefaultValue(denominator, String.valueOf(matuom.getDenominator()), "0")));

          matuom.setEan(ean);
          matuom.setVariant(variant);

          if (matuom.getNumerator() == 0)
          {
            result = false;
            setErrorMessage("Material " + material + " UOM [" + uom + "]. Numerator cannot be zero.");
          } else
          {
            if (matuom.getDenominator() == 0)
            {
              result = false;
              setErrorMessage("Material " + material + " UOM [" + uom + "]. Denominator cannot be zero.");
            } else
            {
              if (matuom.update() == false)
              {
                result = false;
                setErrorMessage("Material " + material + " UOM [" + uom + "] update error. " + matuom.getErrorMessage());
              }
            }
          }

        } catch (Exception ex)
        {
          result = false;
          setErrorMessage("Material " + material + " UOM [" + uom + "]. Invalid Quantity");
        }

      } else
      {
        repeat = false;
      }
      seq++;
      if (matUOMError.equals("")==false)
      {
        setErrorMessage(matUOMError);
      }

    } while (repeat);

    if (mat.getMaterialProperties(material) == false)
    {
      mat.setBaseUom(JUtility.getDefaultValue(base_uom, mat.getBaseUom(), ""));
      if (mat.create() == false)
      {
        result = false;
        setErrorMessage("Material " + material + " create error. " + mat.getErrorMessage());
      } else
      {
        setErrorMessage("Material " + material + " created.");
      }
    }
   
    if (uomdb.isValidInternalUom(uom)==false)
    {
      uomdb.create(weight_uom, weight_uom, weight_uom, "Auto created UOM");
    }

    mat.setMaterialType(JUtility.getDefaultValue(materialType, mat.getMaterialType(), ""));
    mat.setDescription(JUtility.getDefaultValue(description, mat.getDescription(), "No description"));
    mat.setBaseUom(JUtility.getDefaultValue(base_uom, mat.getBaseUom(), ""));
    mat.setShelfLifeUom(JUtility.getDefaultValue(shelf_life_uom, mat.getShelfLifeUom(), "D"));
    mat.setEquipmentType(JUtility.getDefaultValue(equipment_type, mat.getEquipmentType(), ""));
    mat.setShelfLife(Integer.valueOf(JUtility.getDefaultValue(shelf_life, String.valueOf(mat.getShelfLife()), "0")));
    mat.setShelfLifeRule(JUtility.getDefaultValue(shelf_life_rule, mat.getShelfLifeRule(), "+"));
    mat.setGrossWeight(BigDecimal.valueOf(Double.valueOf(JUtility.getDefaultValue(gross_weight, mat.getGrossWeight().toString(), "0.0"))));
    mat.setNetWeight(BigDecimal.valueOf(Double.valueOf(JUtility.getDefaultValue(net_weight, mat.getNetWeight().toString(), "0.0"))));
    mat.setWeightUom(JUtility.getDefaultValue(weight_uom, mat.getWeightUom(), ""));
    mat.setOldMaterial(JUtility.getDefaultValue(old_material, mat.getOldMaterial(), ""));
    mat.setInspectionID(JUtility.getDefaultValue(inspection_id, mat.getInspectionID(), ""));
    mat.setDefaultBatchStatus(JUtility.getDefaultValue(default_batch_status, mat.getDefaultBatchStatus(), defaultBatchStatus));

    if (mat.update() == false)
    {
      result = false;
      setErrorMessage("Material " + material + " update error. " + mat.getErrorMessage());
    }

    mat = null;

    return result;
View Full Code Here

    lmaterial = JOptionPane.showInputDialog(Common.mainForm, lang.get("dlg_Material_Input"));
    if (lmaterial != null)
    {
      if (lmaterial.equals("") == false)
      {
        JDBMaterial mat = new JDBMaterial(Common.selectedHostID, Common.sessionID);
        if (mat.isValidMaterial(lmaterial))
        {
          lbatch = JOptionPane.showInputDialog(Common.mainForm, lang.get("dlg_Material_Batch_Input"));
          if (lbatch != null)
          {
            if (lbatch.equals("") == false)
View Full Code Here

      }
      jButtonUpdate.setEnabled(false);
    }
    else
    {
      JDBMaterial mat = new JDBMaterial(Common.selectedHostID, Common.sessionID);
      mat.getMaterialProperties(material);
      jComboBoxStatus.setSelectedItem(mat.getDefaultBatchStatus());

      Date de = JUtility.getSQLDateTime();
      try
      {
        dateTimePicker.setDate(mat.calcBBE(de, mat.getShelfLife(), mat.getShelfLifeUom(), mat.getShelfLifeRule()));
      }
      catch (Exception e)
      {

      }
View Full Code Here

    Boolean result = false;
    String path = "";
    JDBInterfaceLog il = new JDBInterfaceLog(getHostID(), getSessionID());
    GenericMessageHeader gmh = new GenericMessageHeader();
    JDBInterface inter = new JDBInterface(getHostID(), getSessionID());
    JDBMaterial mat = new JDBMaterial(getHostID(), getSessionID());
    JDBCustomer cust = new JDBCustomer(getHostID(), getSessionID());
    inter.getInterfaceProperties("Label Data", "Output");
    String device = inter.getDevice();
    String format = inter.getFormat();
    JDBLabelData labdata = new JDBLabelData(getHostID(), getSessionID());

    if (labdata.getProperties(unique))
    {

      try
      {
        if (format.equals("CSV"))
        {

          if (device.equals("Disk"))
          {
            String heading[] = labdata.getDataArray(unique, "heading");
            String data[] = labdata.getDataArray(unique, "data");

            path = inter.getRealPath();

            path = path.replace("\\", java.io.File.separator);
            path = path.replace("/", java.io.File.separator);

            if (path.length() > 0)
            {
              if (path.substring(path.length() - 1).equals(java.io.File.separator) == false)
              {
                path = path + java.io.File.separator;
              }
            }
            String filename = path + "LabelData_"+labdata.getLine() + "_" + unique + ".csv";

            CSVWriter writer = new CSVWriter(new FileWriter(filename), ',');
            writer.writeNext(heading);
            writer.writeNext(data);
            writer.close();
            result = true;
            il.write(gmh, GenericMessageHeader.msgStatusSuccess, "Processed OK", "File Write", filename);
            setErrorMessage("");
          }
        }

        if (format.equals("XML"))
        {

          DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
          DocumentBuilder builder = factory.newDocumentBuilder();

          Document document = builder.newDocument();

          Element message = (Element) document.createElement("message");

          Element hostUniqueID = addElement(document, "hostRef", Common.hostList.getHost(getHostID()).getUniqueID());
          message.appendChild(hostUniqueID);

          Element messageRef = addElement(document, "messageRef", unique);
          message.appendChild(messageRef);

          Element messageType = addElement(document, "interfaceType", "Label Data");
          message.appendChild(messageType);

          Element messageInformation = addElement(document, "messageInformation", "UniqueID=" + unique);
          message.appendChild(messageInformation);

          Element messageDirection = addElement(document, "interfaceDirection", "Output");
          message.appendChild(messageDirection);

          Element messageDate = addElement(document, "messageDate", JUtility.getISOTimeStampStringFormat(JUtility.getSQLDateTime()));
          message.appendChild(messageDate);

          Element labelData = (Element) document.createElement("labelData");

          Element unq = addElement(document, "uniqueID", unique);
          labelData.appendChild(unq);

          Element lt = addElement(document, "labelType", labdata.getLabelType());
          labelData.appendChild(lt);

          Element line = addElement(document, "line", labdata.getLine());
          labelData.appendChild(line);

          Element printDate = addElement(document, "printDate", JUtility.getISOTimeStampStringFormat(labdata.getPrintDate()));
          labelData.appendChild(printDate);

          Element user = addElement(document, "userID", labdata.getUserID());
          labelData.appendChild(user);

          Element workstation = addElement(document, "workstation", labdata.getWorkstationID());
          labelData.appendChild(workstation);

          Element material = addElement(document, "material", labdata.getMaterial());
          labelData.appendChild(material);

          if (mat.getMaterialProperties(labdata.getMaterial()))
          {
            Element materialDesc = addElement(document, "materialDescription", mat.getDescription());
            labelData.appendChild(materialDesc);
          }

          Element materialType = addElement(document, "materialType", labdata.getMaterialType());
          labelData.appendChild(materialType);
View Full Code Here

  public Boolean processMessage(GenericMessageHeader gmh)
  {
    Boolean result = false;

    JDBPallet pal = new JDBPallet(getHostID(), getSessionID());
    JDBMaterial mat = new JDBMaterial(getHostID(), getSessionID());

    String sscc = gmh.getXMLDocument().findXPath("//message/messageData/productionDeclaration/SSCC").trim();
    confirmed = gmh.getXMLDocument().findXPath("//message/messageData/productionDeclaration/confirmed").trim().toUpperCase();

    if (pal.getPalletProperties(sscc) == false)
    {
      pal.setSSCC(sscc);
      pal.setProcessOrder(gmh.getXMLDocument().findXPath("//message/messageData/productionDeclaration/processOrder").trim());
      pal.setUom(gmh.getXMLDocument().findXPath("//message/messageData/productionDeclaration/productionUOM").trim());
      if (pal.populateFromProcessOrder() == true)
      {

        pal.setBatchNumber(gmh.getXMLDocument().findXPath("//message/messageData/productionDeclaration/batch").trim());
        pal.setQuantity(new BigDecimal(gmh.getXMLDocument().findXPath("//message/messageData/productionDeclaration/productionQuantity").trim()));

        String prodDateString = gmh.getXMLDocument().findXPath("//message/messageData/productionDeclaration/productionDate").trim();
        Timestamp prodDateTime = JUtility.getTimeStampFromISOString(prodDateString);

        String expireString = gmh.getXMLDocument().findXPath("//message/messageData/productionDeclaration/expiryDate").trim();
        Timestamp expireTime = JUtility.getTimeStampFromISOString(expireString);

        if (expireTime == null)
        {
          result = false;
          setErrorMessage("SSCC " + pal.getSSCC() + " Expiry Date in wrong format (" + expireString + ") yyyy-mm-ddThh:mm:ss");
        }
        else
        {

          pal.setBatchExpiry(JUtility.getTimestampFromDate(mat.getRoundedExpiryTime(expireTime)));

          if (pal.getBatchExpiry().before(prodDateTime))
          {
            result = false;
            setErrorMessage("SSCC " + pal.getSSCC() + " has Expiry Date before Production Date.");
View Full Code Here

    String path = "";
    JDBInterfaceLog il = new JDBInterfaceLog(getHostID(), getSessionID());
    GenericMessageHeader gmh = new GenericMessageHeader();
    JDBInterface inter = new JDBInterface(getHostID(), getSessionID());
    JDBUom uom = new JDBUom(getHostID(), getSessionID());
    JDBMaterial mat = new JDBMaterial(getHostID(), getSessionID());
    JDBControl ctrl = new JDBControl(getHostID(), getSessionID());

    String expiryMode;
    expiryMode = ctrl.getKeyValue("EXPIRY DATE MODE");

    inter.getInterfaceProperties("Production Declaration", "Output");
    String device = inter.getDevice();

    JDBPalletHistory palhist = new JDBPalletHistory(getHostID(), getSessionID());
    ResultSet rs = palhist.getInterfacingData(transactionRef, "PROD DEC", "CONFIRM", Long.valueOf(1), "SSCC", "asc");
    try
    {
      if (rs.next())
      {
        palhist.getPropertiesfromResultSet(rs);

        try
        {
          DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
          DocumentBuilder builder = factory.newDocumentBuilder();

          Document document = builder.newDocument();

          Element message = (Element) document.createElement("message");

          Element hostUniqueID = addElement(document, "hostRef", Common.hostList.getHost(getHostID()).getUniqueID());
          message.appendChild(hostUniqueID);

          Element messageRef = addElement(document, "messageRef", String.valueOf(transactionRef));
          message.appendChild(messageRef);

          Element messageType = addElement(document, "interfaceType", "Production Declaration");
          message.appendChild(messageType);

          Element messageInformation = addElement(document, "messageInformation", "SSCC=" + palhist.getPallet().getSSCC());
          message.appendChild(messageInformation);

          Element messageDirection = addElement(document, "interfaceDirection", "Output");
          message.appendChild(messageDirection);

          Element messageDate = addElement(document, "messageDate", JUtility.getISOTimeStampStringFormat(JUtility.getSQLDateTime()));
          message.appendChild(messageDate);

          Element productionDeclaration = (Element) document.createElement("productionDeclaration");

          Element sscc = addElement(document, "SSCC", palhist.getPallet().getSSCC());
          productionDeclaration.appendChild(sscc);

          Element processOrder = addElement(document, "processOrder", palhist.getPallet().getProcessOrder());
          productionDeclaration.appendChild(processOrder);

          Element recipe = addElement(document, "recipe", palhist.getPallet().getProcessOrderObj(false).getRecipe());
          productionDeclaration.appendChild(recipe);

          Element required_resource = addElement(document, "requiredResource", palhist.getPallet().getProcessOrderObj(false).getRequiredResource());
          productionDeclaration.appendChild(required_resource);
         
          Element material = addElement(document, "material", palhist.getPallet().getMaterial());
          productionDeclaration.appendChild(material);

          if (mat.getMaterialProperties(palhist.getPallet().getMaterial()) == true)
          {
            Element description = addElement(document, "description", mat.getDescription());
            productionDeclaration.appendChild(description);
            Element old_code = addElement(document,"old_code",mat.getOldMaterial());
            productionDeclaration.appendChild(old_code);
          }
          else
          {
            Element description = addElement(document, "description", "");
View Full Code Here

    try
    {
      if (cache.containsKey(row)==false)
      {
        mResultSet.absolute(row + 1);
        final JDBMaterial prow = new JDBMaterial(Common.selectedHostID, Common.sessionID);
        prow.getPropertiesfromResultSet(mResultSet);
        cache.put(row, prow);
      }

      switch (col)
      {
View Full Code Here

    lmaterial = JOptionPane.showInputDialog(Common.mainForm, lang.get("dlg_Material_Input"));
    if (lmaterial != null)
    {
      if (lmaterial.equals("") == false)
      {
        JDBMaterial mat = new JDBMaterial(Common.selectedHostID, Common.sessionID);
        if (mat.isValidMaterial(lmaterial))
        {
          llocation = JOptionPane.showInputDialog(Common.mainForm, lang.get("dlg_Material_Location_Input"));
          if (llocation != null)
          {
            if (llocation.equals("") == false)
View Full Code Here

TOP

Related Classes of com.commander4j.db.JDBMaterial

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.