How to find report by report name in Windchill

public static ObjectIdentifier findReportObjectIdByName(String reportName) throws Exception{
    QuerySpec queryspec = new QuerySpec();
    int i = queryspec.appendClassList(Report.class, false);
    queryspec.appendSelectAttribute("thePersistInfo.theObjectIdentifier.classname", i, false);
    queryspec.appendSelectAttribute("thePersistInfo.theObjectIdentifier.id", i, false);
    SearchCondition searchcondition = new SearchCondition(Report.class, Report.NAME, "=", reportName, false);
    queryspec.appendWhere(searchcondition);
    QueryResult queryresult = PersistenceHelper.manager.find(queryspec);

if(queryresult == null || !queryresult.hasMoreElements()){
        return null;
    }
    Object aobj[] = (Object[])(Object[])queryresult.nextElement();
    String s1 = (String)aobj[0];
    long l = ((Number)aobj[1]).longValue();
    return ObjectIdentifier.newObjectIdentifier(Class.forName(s1), l);
}

你可能感兴趣的:(How to find report by report name in Windchill)