Esempio n. 1
0
  public CompositeData getNextEntry(Object[] indexObjects) {

    // User code starts here
    if (!agentName.initAlert()) return null;

    String previousKeys[] = {indexObjects[0].toString(), indexObjects[1].toString()};
    String keys[] = getNextAlert(previousKeys);

    if (keys == null) return null;

    String source = keys[0];

    // String ownerName = keys[1];

    String entity = keys[1];

    Alert alert1 = new Alert();

    alert1.setSource(source);

    //	alert1.setOwnerName(ownerName);

    alert1.setEntity(entity);

    Alert alert2 = new Alert();

    alert2.setModTime(System.currentTimeMillis());

    Vector alerts = null;

    try {
      alerts = agentName.alertAPI.getAlerts(alert1, alert2);

      if (alerts != null) return makeComData((Alert) alerts.elementAt(0));
    } catch (Exception e) {
      return null;
    }

    // User code ends here
    return null;
  }
Esempio n. 2
0
  /**
   * Sets the TabularData to the AaplicationTable
   *
   * @param data The TabularData to be set to the AaplicationTable
   */
  public void setAlarmTable(TabularData data) throws Exception {
    AgentException ae = null;

    for (Enumeration e = data.enumerate(); e.hasMoreElements(); ) {
      Object[] index = (Object[]) e.nextElement();
      CompositeData comp = data.getRow(index);

      if (table != null)
        entry =
            (AlarmEntry)
                Utilities.getEntryFromCompositeData(table, comp, indexNames, instrClassName);
      else if (vec != null)
        entry =
            (AlarmEntry) Utilities.getEntryFromCompositeData(vec, comp, indexNames, instrClassName);

      if (comp.getOperationType().equals(CompositeData.CREATED)) { // create new entry

        if (entry != null)
          throw new AgentException("Row already exist", CommonUtils.ROWCREATIONFAILED); // no i18n
        entry = new AlarmEntry();

        if (table != null) table.put(index, entry);
        else if (vec != null) vec.addElement(entry);
        for (Enumeration ce = comp.enumerate(); ce.hasMoreElements(); ) {
          String key = (String) ce.nextElement();
          try {
            Utilities.setField(entry, instrClassName, key, comp.getDataItem(key));
          } catch (AgentException aexp) {
            ae = aexp;
          }
        }
      } else if (comp.getOperationType().equals(CompositeData.DELETED)) {

        if (table != null) {
          for (Enumeration en = table.keys(); en.hasMoreElements(); ) {
            Object keyObject = en.nextElement();
            if (entry.equals(table.get(keyObject))) table.remove(keyObject);
          }
        } else if (vec != null)
          if (!vec.removeElement(entry))
            throw new AgentException("Invalid Index", CommonUtils.INVALIDINDEX); // no i18n
        data.deleteRow(index);
      } else if (comp.getOperationType().equals(CompositeData.MODIFIED)) {

        for (Enumeration ce = comp.enumerate(); ce.hasMoreElements(); ) {
          String key = (String) ce.nextElement();
          if (!comp.isModified(key)) continue;
          try {

            Utilities.setField(entry, instrClassName, key, comp.getDataItem(key));
          } catch (AgentException aexp) {
            ae = aexp;
          }
        }
      }

      comp.setOperationType(CompositeData.NOCHANGES);
    }

    if (ae != null) throw ae;
  }