Search in sources :

Example 1 with Triplet

use of alma.alarmsystem.Triplet in project ACS by ACS-Community.

the class IDLSendAlarmTest method testSendAlarmThroughIDL.

/**
	 * Send an alarm with the IDL method
	 * 
	 * @throws Exception
	 */
public void testSendAlarmThroughIDL() throws Exception {
    // Build the alarm
    Triplet triplet = new Triplet(IDLTestFF, IDLTestFM, IDLTestFC);
    long timestamp = UTCUtility.utcJavaToOmg(System.currentTimeMillis());
    org.omg.CosPropertyService.Property[] props = new org.omg.CosPropertyService.Property[0];
    alarmService.submitAlarm(triplet, true, "ThisHostName", this.getClass().getName(), timestamp, props);
    logger.info("Alarm sent. Now waiting for alarms");
    long timeout = System.currentTimeMillis() + 60 * 1000;
    do {
        try {
            Thread.sleep(500);
        } catch (InterruptedException e) {
            continue;
        }
        if (alarms.size() > 0) {
            break;
        }
    } while (System.currentTimeMillis() < timeout);
    assertEquals(1, alarms.size());
}
Also used : Triplet(alma.alarmsystem.Triplet) Property(org.omg.CosPropertyService.Property)

Example 2 with Triplet

use of alma.alarmsystem.Triplet in project ACS by ACS-Community.

the class LaserComponent method fromBusinessAlarm.

/**
	 * Helper method which converts EJB business Alarm to CORBA Alarm structure.
	 * @param alarm
	 * @return
	 */
private Alarm fromBusinessAlarm(cern.laser.business.data.Alarm alarm) {
    cern.laser.business.data.Triplet bt = alarm.getTriplet();
    cern.laser.business.data.Location bl = alarm.getLocation();
    if (bl.getBuilding() == null) {
        bl.setBuilding(new Building("", "", 1, ""));
    }
    cern.laser.business.data.Status bs = alarm.getStatus();
    // Build the properties
    Property[] props;
    if (alarm.getStatus().getProperties() != null) {
        props = new Property[alarm.getStatus().getProperties().size()];
        Set keys = alarm.getStatus().getProperties().keySet();
        int t = 0;
        for (Object key : keys) {
            String name = (String) key;
            String value = alarm.getStatus().getProperties().getProperty(name);
            Any any = corbaServer.getORB().create_any();
            any.insert_string(value);
            props[t++] = new Property(name, any);
        }
    } else {
        props = new Property[0];
    }
    Alarm newAlarm = new Alarm(alarm.getAlarmId(), new Triplet(bt.getFaultFamily(), bt.getFaultMember(), bt.getFaultCode().intValue()), getString(alarm.getSystemName()), getString(alarm.getIdentifier()), getString(alarm.getProblemDescription()), alarm.getPriority().intValue(), getString(alarm.getCause()), getString(alarm.getAction()), getString(alarm.getConsequence()), fromBusinessSource(alarm.getSource()), getString(alarm.getHelpURL().toExternalForm()), getString(alarm.getPiquetGSM()), getString(alarm.getPiquetEmail()), fromBusinessResponsiblePerson(alarm.getResponsiblePerson()), new Location(bl.getLocationId(), bl.getFloor(), bl.getRoom(), bl.getPosition(), bl.getMnemonic(), bl.getBuilding().getBuildingNumber(), bl.getBuilding().getSite(), bl.getBuilding().getZone().intValue(), bl.getBuilding().getMap()), fromBusinessCategoryCollection(alarm.getCategories()), new Status(bs.getActive().booleanValue(), bs.getMasked().booleanValue(), bs.getReduced().booleanValue(), new Timestamp(bs.getSourceTimestamp().getTime(), bs.getSourceTimestamp().getNanos()), bs.getSourceHostname(), new Timestamp(bs.getUserTimestamp().getTime(), bs.getUserTimestamp().getNanos()), new Timestamp(bs.getSystemTimestamp().getTime(), bs.getSystemTimestamp().getNanos()), props), alarm.getInstant().booleanValue(), alarm.hasNodeParents(), alarm.hasMultiplicityParents(), alarm.hasNodeChildren(), alarm.hasMultiplicityChildren());
    return newAlarm;
}
Also used : Building(cern.laser.business.data.Building) Status(alma.alarmsystem.Status) Set(java.util.Set) Triplet(alma.alarmsystem.Triplet) Any(org.omg.CORBA.Any) Timestamp(alma.alarmsystem.Timestamp) Alarm(alma.alarmsystem.Alarm) Property(org.omg.CosPropertyService.Property) Location(alma.alarmsystem.Location)

Aggregations

Triplet (alma.alarmsystem.Triplet)2 Property (org.omg.CosPropertyService.Property)2 Alarm (alma.alarmsystem.Alarm)1 Location (alma.alarmsystem.Location)1 Status (alma.alarmsystem.Status)1 Timestamp (alma.alarmsystem.Timestamp)1 Building (cern.laser.business.data.Building)1 Set (java.util.Set)1 Any (org.omg.CORBA.Any)1