コード例 #1
0
ファイル: Filler.java プロジェクト: djw1149/cougaar-logistics
  protected void addContentsInfo(GLMAsset container, List agglist) {
    ArrayList typeIDs = new ArrayList();
    ArrayList nomenclatures = new ArrayList();
    ArrayList weights = new ArrayList();
    ArrayList receivers = new ArrayList();

    for (Iterator iterator = agglist.iterator(); iterator.hasNext(); ) {
      Task task = (Task) iterator.next();
      TypeIdentificationPG typeIdentificationPG = task.getDirectObject().getTypeIdentificationPG();
      String typeID;
      String nomenclature;
      if (typeIdentificationPG != null) {
        typeID = typeIdentificationPG.getTypeIdentification();
        if ((typeID == null) || (typeID.equals(""))) {
          typeID = UNKNOWN;
        }

        nomenclature = typeIdentificationPG.getNomenclature();
        if ((nomenclature == null) || (nomenclature.equals(""))) {
          nomenclature = UNKNOWN;
        }
      } else {
        typeID = UNKNOWN;
        nomenclature = UNKNOWN;
      }
      typeIDs.add(typeID);
      nomenclatures.add(nomenclature);

      double quantity = task.getPreferredValue(AspectType.QUANTITY);
      Mass mass = Mass.newMass(quantity, Mass.SHORT_TONS);
      weights.add(mass);

      String receiverID;
      if (FIND_FOR_UNIT_PREP_ON_TASK) {
        receiverID = getReceiverID(task);
      } else {
        receiverID = _gp.getGPMessageAddress().getAddress();
      }

      _gp.getLoggingService()
          .info(
              "Adding - "
                  + task.getUID()
                  + " for "
                  + receiverID
                  + " - "
                  + typeID
                  + " - "
                  + quantity);
      packer.addToReceiver(receiverID, typeID, quantity);

      receivers.add(receiverID);
    }

    // Contents
    NewContentsPG contentsPG = PropertyGroupFactory.newContentsPG();
    contentsPG.setNomenclatures(nomenclatures);
    contentsPG.setTypeIdentifications(typeIDs);
    contentsPG.setWeights(weights);
    contentsPG.setReceivers(receivers);
    container.setContentsPG(contentsPG);
  }