cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can Bookmark boards, posts or articles that you'd like to access again easily! X

How to find the baseline for a PromotionNotice?

RandyJones
19-Tanzanite

How to find the baseline for a PromotionNotice?

Windchill 9.1 M070

I am attempting to remove objects from a PromotionNotice's baseline that are not set for promotion.My initial problem is figuring out how to find the baseline for the PromotionNotice. I am attempting to do this in an expression robot in the promotion request workflow as follows:

wt.maturity.PromotionNotice pbo = (wt.maturity.PromotionNotice)primaryBusinessObject;

//get the promotion request baseline
wt.fc.collections.WTCollection collection= new wt.fc.collections.WTArrayList();
collection.add(pbo);
wt.vc.baseline.Baseline pnBaseLine = null;
wt.fc.collections.WTKeyedMap pnBaseLineWTKM = wt.vc.baseline.BaselineHelper.service.getBaselines(collection, wt.vc.baseline.ManagedBaseline.class);
//******The following is returning null
pnBaseLine = (wt.vc.baseline.Baseline)pnBaseLineWTKM.get(pbo);

***at this point pnBaseLine == null
***I was expecting to have a Baseline
***What obvious java/Windchill thingy am I missing here?



//get the objects actually getting promoted
//this works
wt.fc.QueryResult pnTargets = wt.maturity.MaturityHelper.service.getPromotionTargets(pbo);

//get the all the objects in the promotion notices baseline
//this works
wt.fc.QueryResult pnBaseLineItems = wt.maturity.MaturityHelper.service.getBaselineItems(pbo);

//some logic that figures out what objects exist in pnBaseLineItems that do not exist in pnTargets
//this logic is working
.
.
.


//And finally to remove an object from the baseline I think this is what I need
//however at this point I don't have a Baseline to remove from
EPMDocument someEPMDocFromAboveLogic;
wt.vc.baseline.BaselineHelper.service.removeFromBaseline(someEPMDocFromAboveLogic, pnBaseLine);


So my problem is that I can't figure out how to find the baseline for the promotion request. I am probably missing something obvious here.


Thanks

--
2 REPLIES 2

Randy, hi

try either

MaturityBaseline baseline = pn.getConfiguration();
QueryResult qr = BaselineHelper.service.getBaselineItems(baseline);

or

QueryResult qr = MaturityHelper.getService().getBaselineItems(pn); // 10.x
in 9.x this is probably
QueryResult qr = MaturityHelper.service.getBaselineItems(pn);
//MaturityHelper.service is deprecated in 10.1

where pn is the PromotionNotice object

I have not tested but it should work

David Graham
Windchill Developer/Administrator
CAx Administrator


Emhart Glass Manufacturing Inc.
Emhart Glass Research Center
123 Great Pond Drive | Windsor, CT 06095 | USA
Telephone +1 (203) 376-3144 | Telefax +1 (860) 298 7397
Mobile +1 (203) 376-3144 |

I have figured this out.

Thanks to David for the handy tip of:
MaturityBaseline baseline = pn.getConfiguration();


So my code to find objects on the promotion request that are not getting promoted and then remove
them from the promotion request's baseline is this:
//pn already set:
//wt.maturity.PromotionNotice pn

//get the objects actually getting promoted
wt.fc.QueryResult pnTargets = wt.maturity.MaturityHelper.service.getPromotionTargets(pn);
//get all the objects on the promotion notice baseline
wt.fc.QueryResult pnBaseLineItems = wt.maturity.MaturityHelper.service.getBaselineItems(pn);

java.util.HashMap<string, wt.epm.epmdocument="> hmPNTargets = new HashMap<string, <br="/>wt.epm.EPMDocument>();//holds Promotion Targets by number
java.util.HashMap<string, wt.epm.epmdocument="> hmPNBaseLineItems = new HashMap<string, <br="/>wt.epm.EPMDocument>();//holds Promotion BaseLineItems by number

//loop thru the BaseLine items and put them in their hashmap
while (pnBaseLineItems.hasMoreElements())
{
     Object obj = pnBaseLineItems.nextElement();
     EPMDocument epmDoc = (wt.epm.EPMDocument)obj;
     hmPNBaseLineItems.put(epmDoc.getNumber(), epmDoc);
}

//loop thru the Promotion targets and put them in their hashmap
while (pnTargets.hasMoreElements())
{
     Object obj = pnTargets.nextElement();
EPMDocument epmDoc = (wt.epm.EPMDocument)obj;
     hmPNTargets.put(epmDoc.getNumber(), epmDoc);
}

//check to see if we have different number of baselines and promotables
if(hmPNTargets.size() != hmPNBaseLineItems.size())
{
     //loop thru baseline objects to delete objects from baseline that are not in the promotable objects
     for (Map.Entry<string, wt.epm.epmdocument="> entry : hmPNBaseLineItems.entrySet())
     {
         String partNumber = entry.getKey();
wt.epm.EPMDocument epmDoc = entry.getValue();
         if(hmPNTargets.get(partNumber) == null)
         {
             //We have a baselines object that does NOT exist in the promotables
             //this needs to be removed
wt.vc.baseline.BaselineHelper.service.removeFromBaseline(epmDoc, pnBaseLine);
         }
     }
}


Announcements


Top Tags