Date cDay=null;   Subscription oplanSubscription = psc.getServerPluginSupport().subscribe(this, oplanPredicate()); Collection oplanCollection = ((CollectionSubscription)oplanSubscription).getCollection(); if (!oplanCollection.isEmpty()) { Oplan plan = (Oplan) ((CollectionSubscription)oplanSubscription).first(); cDay = plan.getCday(); psc.getServerPluginSupport().unsubscribeForSubscriber(oplanSubscription); }
Date startDay=getStartDate(psc);
  private void myExecute( PrintStream out,		       HttpInput query_parameters,		       PlanServiceContext psc,		       PlanServiceUtilities psu) throws Exception {    desiredAssetName = "";    if (query_parameters.hasBody()) {      desiredAssetName = query_parameters.getBodyAsString();      desiredAssetName = desiredAssetName.trim();      System.out.println("POST DATA: " + desiredAssetName);    } else {      System.out.println("WARNING: No asset to plot");      return;    }    // return list of asset names    if (desiredAssetName.equals(ASSET)||	desiredAssetName.startsWith(ASSET_AND_CLASSTYPE)) {	DemandObjectPredicate assetNamePredicate;	//AssetPredicate assetNamePredicate;	if(desiredAssetName.startsWith(ASSET_AND_CLASSTYPE)) {	    String desiredClassType = desiredAssetName.substring(ASSET_AND_CLASSTYPE.length());	    assetNamePredicate = new DemandObjectPredicate(desiredClassType);	    //assetNamePredicate = new AssetPredicate(desiredClassType);	}	else {	    assetNamePredicate = new DemandObjectPredicate();	    //assetNamePredicate = new AssetPredicate();	}	// Asset no demand type handling	/***	 **	 *      Vector assetNames = new Vector();      Subscription subscription = 	psc.getServerPlugInSupport().subscribe(this, assetNamePredicate);      Collection container = 	((CollectionSubscription)subscription).getCollection();      for (Iterator i = container.iterator(); i.hasNext(); ) {	GLMAsset asset = (GLMAsset)(i.next());	TypeIdentificationPG typeIdPG = 	  asset.getScheduledContentPG().getAsset().getTypeIdentificationPG();	String nomenclature = typeIdPG.getNomenclature();	String typeId = typeIdPG.getTypeIdentification();	if (nomenclature != null)	  nomenclature = nomenclature + ":" + typeId;	else	  nomenclature = typeId;	assetNames.addElement(nomenclature);      }       ***       * MWD fix and try this out -below       * MWD get rid of old commented out above replaced by below       * to get demand even where no inventories.       ****/              HashSet assetNamesSet = new HashSet();       Subscription subscription =          psc.getServerPlugInSupport().subscribe(this, assetNamePredicate);      Collection container = 	((CollectionSubscription)subscription).getCollection();      for (Iterator i = container.iterator(); i.hasNext(); ) {	Asset asset = ((Task)(i.next())).getDirectObject();	TypeIdentificationPG typeIdPG = asset.getTypeIdentificationPG();	String nomenclature = typeIdPG.getNomenclature();	String typeId = typeIdPG.getTypeIdentification();	if (nomenclature != null)	  nomenclature = nomenclature + ":" + typeId;	else	  nomenclature = typeId;	assetNamesSet.add(nomenclature);      }      Vector assetNames = new Vector(assetNamesSet);            // unsubscribe, don't need this subscription any more      psc.getServerPluginSupport().unsubscribeForSubscriber(subscription);      // send the results      ObjectOutputStream p = new ObjectOutputStream(out);      p.writeObject(assetNames);      System.out.println("Sent asset names");      return;    } // end returning list of asset names    if (desiredAssetName.startsWith("UID:")) {      String desiredAssetUID = desiredAssetName.substring(4);      Subscription subscription = 	psc.getServerPluginSupport().subscribe(this, new AssetUIDPredicate(desiredAssetUID));      Collection collection = 	((CollectionSubscription)subscription).getCollection();      for (Iterator i = collection.iterator(); i.hasNext(); ) {	GLMAsset asset = (GLMAsset)(i.next());	TypeIdentificationPG typeIdPG = 	  asset.getScheduledContentPG().getAsset().getTypeIdentificationPG();	String nomenclature = typeIdPG.getNomenclature();	String typeId = typeIdPG.getTypeIdentification();	if (nomenclature == null)	  return;	desiredAssetName = nomenclature + ":" + typeId;      }      // unsubscribe, don't need this subscription any more      psc.getServerPluginSupport().unsubscribeForSubscriber(subscription);    } // end getting asset name from UID    Date cDay=null;    // get oplan    Subscription oplanSubscription =      psc.getServerPluginSupport().subscribe(this, oplanPredicate());    Collection oplanCollection =      ((CollectionSubscription)oplanSubscription).getCollection();    if (!oplanCollection.isEmpty()) {      Oplan plan = (Oplan) ((CollectionSubscription)oplanSubscription).first();      cDay = plan.getCday();      psc.getServerPluginSupport().unsubscribeForSubscriber(oplanSubscription);    }    // get roles and determine if this cluster is a provider (or consumer)    Subscription roleSubscription =      psc.getServerPluginSupport().subscribe(this,        new RolePredicate(psc.getServerPluginSupport().getClusterIDAsString()));    Collection roleCollection =      ((CollectionSubscription)roleSubscription).getCollection();    boolean provider = false;    if (!roleCollection.isEmpty()) {      Organization asset = (Organization) ((CollectionSubscription)roleSubscription).first();      Collection roles = asset.getOrganizationPG().getRoles();      Iterator i = roles.iterator();      while (i.hasNext()) {	Role role = (Role)i.next();	if (role.getName().endsWith("Provider")) {	  provider = true;	  break;	}      }    }    psc.getServerPluginSupport().unsubscribeForSubscriber(roleSubscription);    // get asset and tasks we need to create the inventory    InventoryPredicate inventoryPredicate =       new InventoryPredicate(desiredAssetName, 		     psc.getServerPluginSupport().getClusterIDAsString());    Subscription subscription =       psc.getServerPluginSupport().subscribe(this, inventoryPredicate);    Collection collection =       ((CollectionSubscription)subscription).getCollection();    if (collection.isEmpty())      return;    // create UIInventory data object from the log plan objects    UIInventoryImpl inventory = getInventoryFromLogPlan(collection);    // unsubscribe, don't need this subscription any more    psc.getServerPluginSupport().unsubscribeForSubscriber(subscription);    // set values in UISimpleInventory, a serializable object    UISimpleInventory simpleInventory =       getInventoryForClient(inventory, provider, cDay);    // send the UISimpleInventory object    if (simpleInventory != null) {      ObjectOutputStream p = new ObjectOutputStream(out);      p.writeObject(simpleInventory);      System.out.println("Sent XML document");    }  }