protected void rehydrate() {
    configure();
    if (logger.isDebugEnabled()) {
      logger.debug("Rehydrated - configured " + configured);
    }
    if (configured) {
      // rehook handlers
      Enumeration consumers = consumerSubscription.elements();
      Asset asset, proto;
      // boolean success;
      Vector good_prototypes = new Vector();

      while (consumers.hasMoreElements()) {
        asset = (Asset) consumers.nextElement();
        if (asset instanceof AggregateAsset) {
          proto = ((AggregateAsset) asset).getAsset();
        } else {
          proto = asset.getPrototype();
        }
        if (proto == null) {
          if (logger.isErrorEnabled()) {
            logger.error("no prototype for " + asset);
          }
        }
        if ((proto != null) && (!good_prototypes.contains(proto))) {
          TypeIdentificationPG tip = asset.getTypeIdentificationPG();
          if (tip != null) {
            String type_id = tip.getTypeIdentification();
            if (type_id != null) {
              getLDM().cachePrototype(type_id, proto);
              good_prototypes.add(proto);
              if (logger.isDebugEnabled()) {
                logger.debug("Rehydrated asset " + asset + " w/ proto " + proto);
              }
            } else {
              if (logger.isErrorEnabled()) {
                logger.error("cannot rehydrate " + proto + " no typeId");
              }
            }
          } else {
            if (logger.isErrorEnabled()) {
              logger.error("cannot rehydrate " + proto + " no typeIdPG");
            }
          }
        }
      } // end while loop
      addConsumerPGs(consumerSubscription);
    }
  }
Ejemplo n.º 2
0
  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);
  }