use of cern.laser.business.data.Location in project ACS by ACS-Community.
the class ACSAlarmDAOImpl method encodeToXML.
static String encodeToXML(StringBuffer result, Alarm alarm) {
result.append("<alarm-definition");
Triplet t = alarm.getTriplet();
if (t == null || t.getFaultCode() == null || t.getFaultFamily() == null || t.getFaultMember() == null)
throw new IllegalArgumentException("Incomplete alarm");
DAOUtil.encodeAttr(result, "fault-family", t.getFaultFamily());
DAOUtil.encodeAttr(result, "fault-member", t.getFaultMember());
DAOUtil.encodeAttr(result, "fault-code", t.getFaultCode().toString());
result.append(">\n");
{
String sn = alarm.getSystemName();
String si = alarm.getIdentifier();
String pd = alarm.getProblemDescription();
if (sn != null || si != null || pd != null) {
result.append("\t<visual-fields>\n");
if (sn != null)
DAOUtil.encodeElem(result, "system-name", sn, 2);
if (si != null)
DAOUtil.encodeElem(result, "identifier", si, 2);
if (pd != null)
DAOUtil.encodeElem(result, "problem-description", pd, 2);
result.append("\t</visual-fields>\n");
}
}
DAOUtil.encodeElemIf(result, "instant", alarm.getInstant(), 1);
DAOUtil.encodeElemIf(result, "cause", alarm.getCause(), 1);
DAOUtil.encodeElemIf(result, "action", alarm.getAction(), 1);
DAOUtil.encodeElemIf(result, "consequence", alarm.getConsequence(), 1);
DAOUtil.encodeElemIf(result, "priority", alarm.getPriority(), 1);
ResponsiblePerson rp = alarm.getResponsiblePerson();
if (rp != null)
DAOUtil.encodeElemIf(result, "responsible-id", rp.getResponsibleId(), 1);
DAOUtil.encodeElemIf(result, "piquetGSM", alarm.getPiquetGSM(), 1);
DAOUtil.encodeElemIf(result, "help-url", alarm.getHelpURL(), 1);
Source s = alarm.getSource();
if (s != null)
DAOUtil.encodeElemIf(result, "source-name", s.getName(), 1);
Location l = alarm.getLocation();
if (l != null) {
result.append("\t<location>\n");
Building b = l.getBuilding();
if (b != null)
DAOUtil.encodeElemIf(result, "building", b.getBuildingNumber(), 2);
DAOUtil.encodeElemIf(result, "floor", l.getFloor(), 2);
DAOUtil.encodeElemIf(result, "room", l.getRoom(), 2);
DAOUtil.encodeElemIf(result, "mnemonic", l.getMnemonic(), 2);
DAOUtil.encodeElemIf(result, "position", l.getPosition(), 2);
result.append("\t</location>\n");
}
DAOUtil.encodeElemIf(result, "piquetEmail", alarm.getPiquetEmail(), 1);
result.append("</alarm-definition>\n");
return result.toString();
}
Aggregations