Search in sources :

Example 6 with Location

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();
}
Also used : Building(cern.laser.business.data.Building) ResponsiblePerson(cern.laser.business.data.ResponsiblePerson) Triplet(cern.laser.business.data.Triplet) Source(cern.laser.business.data.Source) InputSource(org.xml.sax.InputSource) Location(cern.laser.business.data.Location)

Aggregations

Location (cern.laser.business.data.Location)6 ResponsiblePerson (cern.laser.business.data.ResponsiblePerson)6 Source (cern.laser.business.data.Source)6 Triplet (cern.laser.business.data.Triplet)6 AlarmImpl (cern.laser.business.data.AlarmImpl)5 HashSet (java.util.HashSet)5 Building (cern.laser.business.data.Building)3 Category (cern.laser.business.data.Category)3 StatusImpl (cern.laser.business.data.StatusImpl)3 SourceDefinition (cern.laser.business.definition.data.SourceDefinition)3 Timestamp (java.sql.Timestamp)3 Properties (java.util.Properties)3 InputSource (org.xml.sax.InputSource)3 Contact (alma.acs.alarmsystem.generated.Contact)2 FaultCode (alma.acs.alarmsystem.generated.FaultCode)2 FaultFamily (alma.acs.alarmsystem.generated.FaultFamily)2 FaultMember (alma.acs.alarmsystem.generated.FaultMember)2 FaultMemberDefault (alma.acs.alarmsystem.generated.FaultMemberDefault)2 CategoryImpl (cern.laser.business.data.CategoryImpl)2 MalformedURLException (java.net.MalformedURLException)2