4 Replies Latest reply on Jul 9, 2015 8:31 AM by ablyth RSS
    ablyth Apprentice

    Using the AuditBridge.find() method

    Hi,

     

    I am having some difficulty with the AuditBridge class on Machine cloud 6.8.2, i believe the following line of code:

     

    foundEntries = AuditBridge.find(ac)

     

     

    is giving me this error:

     

    No signature of method: static com.axeda.sdk.v2.bridge.AuditBridge.find() is applicable for argument types: (com.axeda.services.v2.AuditCriteria) values: [com.axeda.services.v2.AuditCriteria@50bd993e[assetId=<null>,fromDate=Tue Jun 16 00:00:00 GMT 2015,toDate=Tue Jun 16 10:32:03 GMT 2015,usernames=[],categories=[],pageSize=<null>,pageNumber=1,sortAscending=true,sortPropertyName=date]] Possible solutions: find(), find(groovy.lang.Closure), findAll(), any(), print(java.lang.Object), is(java.lang.Object)

     

    Can anyone see my mistake?

     

    Full Code:

     

    import com.axeda.sdk.v2.bridge.AuditBridge  import static com.axeda.sdk.v2.dsl.Bridges.*; import com.axeda.services.v2.*; import groovy.xml.MarkupBuilder; import java.text.SimpleDateFormat; import java.util.Date; import org.codehaus.groovy.runtime.TimeCategory;  def writer def xml  try {   writer = new StringWriter()   xml = new MarkupBuilder(writer)   SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss")   SimpleDateFormat rsdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss")       AuditCriteria ac = new AuditCriteria()   ac.sortAscending = true    ac.sortPropertyName = 'date'     ac.fromDate = sdf.parse(parameters.RXS_fromDate)   use(TimeCategory) { ac.toDate = new Date() - 10.minutes }    xml.root() {      for (int i = 1; i <= Math.ceil( AuditBridge.find(ac).getTotalCount() / ac.getPageSize()); i++)   {   ac.setPageNumber(i)   foundEntries = AuditBridge.find(ac)   List aList = foundEntries.getAudits()    for (a in aList)   {   xml.Alarm()   {   AuditDate(rsdf.format(a.date))   Msg(a.message)    Category(a.category)   ID(a.asset.systemId)   UserName(a.user.fullName)   UserLogic(a.user.username)   }     }    if (i == 20) { break }   }   } }  catch (Exception ex) {   writer = new StringWriter()   xml = new MarkupBuilder(writer)   xml.Response() {   Fault {   Code('Groovy Exception')   Message(ex.getMessage())   StringWriter sw = new StringWriter();   PrintWriter pw = new PrintWriter(sw);   ex.printStackTrace(pw);   Detail(sw.toString())   }  } }  return ['Content-Type': 'text/xml', 'Content': writer.toString()]