Search in sources :

Example 6 with Triplet

use of cern.laser.business.data.Triplet in project ACS by ACS-Community.

the class AlarmRefMatcher method isMatch.

public boolean isMatch(Alarm a) {
    if (a == null)
        throw new IllegalArgumentException();
    // Checks in order of speed, so failure happens ASAP
    Triplet t = a.getTriplet();
    int code = t.getFaultCode().intValue();
    boolean ret;
    if (code != _code || !_familyPattern.matcher(t.getFaultFamily()).matches() || !_memberPattern.matcher(t.getFaultMember()).matches()) {
        ret = false;
    } else {
        ret = true;
    }
    //System.out.println("\t\t\tMatch "+a.getAlarmId()+" with ["+_familyPattern.toString()+","+_memberPattern.toString()+", "+_code+"] retuned "+ret);
    return ret;
}
Also used : Triplet(cern.laser.business.data.Triplet)

Example 7 with Triplet

use of cern.laser.business.data.Triplet in project ACS by ACS-Community.

the class TestAlarmDAO method testGetAlarmID.

/**
	 * Test the getting of alarms by their ID.
	 * 
	 * it check the alarm, its ID, its triplet, its priority, its description,
	 * action, cause, consequence
	 */
public void testGetAlarmID() throws Exception {
    for (AlarmTriplets triplet : AlarmTriplets.values()) {
        if (!triplet.ID.contains("*")) {
            Alarm alarm = alarmDAO.getAlarm(triplet.ID);
            assertNotNull(alarm);
            // CHeck the ID
            assertEquals(triplet.ID, alarm.getAlarmId());
            // Check the triplet
            Triplet alarmTriplet = alarm.getTriplet();
            assertNotNull(alarmTriplet);
            Triplet defTriplet = triplet.getTriplet();
            assertEquals(defTriplet.getFaultFamily(), alarmTriplet.getFaultFamily());
            assertEquals(defTriplet.getFaultMember(), alarmTriplet.getFaultMember());
            assertEquals(defTriplet.getFaultCode(), alarmTriplet.getFaultCode());
            // Check the priority
            assertEquals(Integer.valueOf(triplet.priority), alarm.getPriority());
            // Check the description
            assertEquals(triplet.description, alarm.getProblemDescription());
            // Action
            assertEquals(triplet.action, alarm.getAction());
            // The cause
            assertEquals(triplet.cause, alarm.getCause());
            // Conseuqnces
            assertEquals(triplet.consequence, alarm.getConsequence());
        }
    }
}
Also used : Triplet(cern.laser.business.data.Triplet) Alarm(cern.laser.business.data.Alarm)

Example 8 with Triplet

use of cern.laser.business.data.Triplet in project ACS by ACS-Community.

the class CategoryClient method convertAlarmType.

/**
	 * Convert a CORBA alarm into a client alarm.
	 * 
	 * @param alarm The CORBA alarm
	 * @return the client alarm
	 */
private Alarm convertAlarmType(alma.alarmsystem.Alarm alarm) {
    Source source = new Source();
    Building building = new Building(alarm.alarmLocation.buildingNb, alarm.alarmLocation.site, alarm.alarmLocation.zone, alarm.alarmLocation.map);
    Location location = new Location(alarm.alarmLocation.locationId, alarm.alarmLocation.floor, alarm.alarmLocation.mnemonic, alarm.alarmLocation.position, alarm.alarmLocation.room);
    location.setBuilding(building);
    ResponsiblePerson responsiblePerson = new ResponsiblePerson(alarm.alarmResponsiblePerson.responsibleId, alarm.alarmResponsiblePerson.familyName, alarm.alarmResponsiblePerson.firstName, alarm.alarmResponsiblePerson.eMail, alarm.alarmResponsiblePerson.gsmNumber, alarm.alarmResponsiblePerson.phoneNumber);
    Properties userProperties = new Properties();
    for (org.omg.CosPropertyService.Property prop : alarm.alarmStatus.userProperties) {
        userProperties.put(prop.property_name, prop.property_value);
    }
    Status status = new StatusImpl(Boolean.valueOf(alarm.alarmStatus.active), Boolean.valueOf(alarm.alarmStatus.masked), Boolean.valueOf(alarm.alarmStatus.reduced), Boolean.FALSE, Boolean.FALSE, alarm.alarmStatus.sourceHostname, new Timestamp(alarm.alarmStatus.sourceTimestamp.miliseconds), new Timestamp(alarm.alarmStatus.userTimestamp.miliseconds), new Timestamp(alarm.alarmStatus.systemTimestamp.miliseconds), userProperties);
    Triplet triplet = new Triplet(alarm.alarmTriplet.faultFamily, alarm.alarmTriplet.faultMember, alarm.alarmTriplet.faultCode);
    Set<cern.laser.business.data.Category> categories = new HashSet<cern.laser.business.data.Category>();
    for (Category cat : alarm.categories) {
        CategoryImpl catImpl = new CategoryImpl(cat.categoryId, cat.name, cat.description, cat.path, cat.leaf);
        categories.add(catImpl);
    }
    cern.laser.business.data.Alarm businessAlarm = new AlarmImpl(alarm.alarmId, alarm.systemName, alarm.identifier, alarm.problemDescription, Integer.valueOf(alarm.priority), alarm.cause, alarm.action, alarm.consequence, alarm.piquetGSM, alarm.piquetEmail, alarm.helpURL, Boolean.valueOf(alarm.instant), source, location, responsiblePerson, categories, status, triplet, alarm.nodeParent, alarm.multiplicityParent, alarm.nodeChild, alarm.multiplicityChild);
    Alarm ret = new cern.laser.client.impl.data.AlarmImpl(businessAlarm);
    return ret;
}
Also used : Building(cern.laser.business.data.Building) Status(cern.laser.business.data.Status) Category(alma.alarmsystem.Category) Triplet(cern.laser.business.data.Triplet) StatusImpl(cern.laser.business.data.StatusImpl) Properties(java.util.Properties) Timestamp(java.sql.Timestamp) Source(cern.laser.business.data.Source) CategoryImpl(cern.laser.business.data.CategoryImpl) ResponsiblePerson(cern.laser.business.data.ResponsiblePerson) AlarmImpl(cern.laser.business.data.AlarmImpl) Alarm(cern.laser.client.data.Alarm) Location(cern.laser.business.data.Location) HashSet(java.util.HashSet)

Example 9 with Triplet

use of cern.laser.business.data.Triplet in project ACS by ACS-Community.

the class ACSAlarmDAOImpl method generateAlarmsMap.

/**
	 * Generate the alarms from the definition of the fault families.
	 * The alarms will be added into the HashMap with their triplet as key.
	 * The default item has FM="*".
	 * 
	 * The sources read from the families are also added to the HashMap of the sources
	 *  
	 * @param families The FF read from the CDB
	 */
public void generateAlarmsMap(Vector<FaultFamily> families) {
    if (families == null) {
        throw new IllegalArgumentException("Invalid null vector of FFs");
    }
    for (FaultFamily family : families) {
        String FF = family.getName();
        String helpUrl = family.getHelpUrl();
        String source = family.getAlarmSource();
        Contact contactPerson = family.getContact();
        FaultMember[] FMs = family.getFaultMember();
        FaultMemberDefault defaultFM = family.getFaultMemberDefault();
        FaultCode[] FCs = family.getFaultCode();
        // There should be at least one FC in the CDB
        if (FCs == null || FCs.length == 0) {
            logger.log(AcsLogLevel.WARNING, "No FC defined for family " + family.getName());
            continue;
        }
        // There should be at least one FM or a default FM defined in the CDB
        if (defaultFM == null && (FMs == null || FMs.length == 0)) {
            logger.log(AcsLogLevel.WARNING, "No FM defined for family " + family.getName());
            continue;
        }
        // Iterate over the FCs
        for (FaultCode code : FCs) {
            int FC = code.getValue();
            int priority = code.getPriority();
            String action = code.getAction();
            String cause = code.getCause();
            String consequence = code.getConsequence();
            String problemDesc = code.getProblemDescription();
            boolean instant = code.getInstant();
            // Iterate over all the FMs
            for (FaultMember member : FMs) {
                alma.acs.alarmsystem.generated.Location loc = member.getLocation();
                if (loc == null) {
                    loc = new alma.acs.alarmsystem.generated.Location();
                }
                if (loc.getBuilding() == null) {
                    loc.setBuilding("");
                }
                if (loc.getFloor() == null) {
                    loc.setFloor("");
                }
                if (loc.getMnemonic() == null) {
                    loc.setMnemonic("");
                }
                if (loc.getPosition() == null) {
                    loc.setPosition("");
                }
                if (loc.getRoom() == null) {
                    loc.setRoom("");
                }
                String FM = member.getName();
                if (FM.equals(DEFAULT_FM)) {
                    logger.log(AcsLogLevel.ERROR, "In the CDB, FM=" + DEFAULT_FM + " in family " + FF + " is not allowed");
                }
                AlarmImpl alarm = new AlarmImpl();
                alarm.setMultiplicityChildrenIds(new HashSet());
                alarm.setMultiplicityParentIds(new HashSet());
                alarm.setNodeChildrenIds(new HashSet());
                alarm.setNodeParentIds(new HashSet());
                alarm.setAction(action);
                alarm.setTriplet(new Triplet(FF, FM, FC));
                alarm.setCategories(new HashSet<Category>());
                alarm.setCause(cause);
                alarm.setConsequence(consequence);
                alarm.setProblemDescription(problemDesc);
                try {
                    alarm.setHelpURL(new URL(helpUrl));
                } catch (MalformedURLException e) {
                    alarm.setHelpURL(null);
                }
                alarm.setInstant(instant);
                Location location = new Location("0", loc.getFloor(), loc.getMnemonic(), loc.getPosition(), loc.getRoom());
                alarm.setLocation(location);
                if (contactPerson.getEmail() != null) {
                    alarm.setPiquetEmail(contactPerson.getEmail());
                } else {
                    alarm.setPiquetEmail("");
                }
                if (contactPerson.getGsm() != null) {
                    alarm.setPiquetGSM(contactPerson.getGsm());
                } else {
                    alarm.setPiquetGSM("");
                }
                alarm.setPriority(priority);
                ResponsiblePerson responsible = new ResponsiblePerson(0, contactPerson.getName(), "", contactPerson.getEmail(), contactPerson.getGsm(), "");
                alarm.setResponsiblePerson(responsible);
                SourceDefinition srcDef = new SourceDefinition(source, "SOURCE", "", 15, 1);
                Source src = new Source(srcDef, responsible);
                alarm.setSource(src);
                alarm.setIdentifier(alarm.getTriplet().toIdentifier());
                alarmDefs.put(alarm.getAlarmId(), alarm);
                if (!srcDefs.containsKey(source)) {
                    srcDefs.put(src.getSourceId(), src);
                    logger.log(AcsLogLevel.DEBUG, "Source " + src.getName() + " (id=" + src.getSourceId() + ") added");
                }
                logger.log(AcsLogLevel.DEBUG, "Alarm added " + alarm.getAlarmId());
            }
            // Add the default
            if (defaultFM != null) {
                alma.acs.alarmsystem.generated.Location loc = defaultFM.getLocation();
                if (loc == null) {
                    loc = new alma.acs.alarmsystem.generated.Location();
                }
                if (loc.getBuilding() == null) {
                    loc.setBuilding("");
                }
                if (loc.getFloor() == null) {
                    loc.setFloor("");
                }
                if (loc.getMnemonic() == null) {
                    loc.setMnemonic("");
                }
                if (loc.getPosition() == null) {
                    loc.setPosition("");
                }
                if (loc.getRoom() == null) {
                    loc.setRoom("");
                }
                AlarmImpl defaultAlarm = new AlarmImpl();
                defaultAlarm.setMultiplicityChildrenIds(new HashSet());
                defaultAlarm.setMultiplicityParentIds(new HashSet());
                defaultAlarm.setNodeChildrenIds(new HashSet());
                defaultAlarm.setNodeParentIds(new HashSet());
                defaultAlarm.setAction(action);
                defaultAlarm.setCategories(new HashSet<Category>());
                defaultAlarm.setCause(cause);
                defaultAlarm.setConsequence(consequence);
                defaultAlarm.setProblemDescription(problemDesc);
                try {
                    defaultAlarm.setHelpURL(new URL(helpUrl));
                } catch (MalformedURLException e) {
                    defaultAlarm.setHelpURL(null);
                }
                defaultAlarm.setInstant(instant);
                Location location = new Location("0", loc.getFloor(), loc.getMnemonic(), loc.getPosition(), loc.getRoom());
                defaultAlarm.setLocation(location);
                defaultAlarm.setPiquetEmail(contactPerson.getEmail());
                defaultAlarm.setPiquetGSM(contactPerson.getGsm());
                defaultAlarm.setPriority(priority);
                ResponsiblePerson responsible = new ResponsiblePerson(0, contactPerson.getName(), "", contactPerson.getEmail(), contactPerson.getGsm(), "");
                defaultAlarm.setResponsiblePerson(responsible);
                SourceDefinition srcDef = new SourceDefinition(source, "SOURCE", "", 15, 1);
                Source src = new Source(srcDef, responsible);
                defaultAlarm.setSource(src);
                defaultAlarm.setIdentifier(defaultAlarm.getTriplet().toIdentifier());
                Triplet triplet = new Triplet(FF, DEFAULT_FM, FC);
                defaultAlarm.setTriplet(triplet);
                defaultAlarm.setIdentifier(triplet.toIdentifier());
                alarmDefs.put(defaultAlarm.getAlarmId(), defaultAlarm);
                if (!srcDefs.containsKey(source)) {
                    srcDefs.put(src.getSourceId(), src);
                    logger.log(AcsLogLevel.DEBUG, "Source " + src.getName() + " (id=" + src.getSourceId() + ") added");
                }
                logger.log(AcsLogLevel.DEBUG, "Default alarm added " + defaultAlarm.getAlarmId());
            }
        }
    }
}
Also used : FaultCode(alma.acs.alarmsystem.generated.FaultCode) MalformedURLException(java.net.MalformedURLException) SourceDefinition(cern.laser.business.definition.data.SourceDefinition) Category(cern.laser.business.data.Category) URL(java.net.URL) Source(cern.laser.business.data.Source) InputSource(org.xml.sax.InputSource) ResponsiblePerson(cern.laser.business.data.ResponsiblePerson) HashSet(java.util.HashSet) FaultMember(alma.acs.alarmsystem.generated.FaultMember) Triplet(cern.laser.business.data.Triplet) Contact(alma.acs.alarmsystem.generated.Contact) FaultMemberDefault(alma.acs.alarmsystem.generated.FaultMemberDefault) FaultFamily(alma.acs.alarmsystem.generated.FaultFamily) AlarmImpl(cern.laser.business.data.AlarmImpl) Location(cern.laser.business.data.Location)

Example 10 with Triplet

use of cern.laser.business.data.Triplet in project ACS by ACS-Community.

the class ReductionManager method getMRParentByTriplet.

/**
	 * Returns an Alarm which is parent in a Multiplicity Reduction Rule, constrained to the given triplet values. 
	 * @param ff The Fault Family of the Alarm
	 * @param fm The Fault Member of the Alarm
	 * @param fc The Fault Code of the Alarm
	 * @return The Alarm described by the triplet, and which is a parent alarm in a Multiplicity Reduction Rule
	 */
public ReductionRule getMRParentByTriplet(String ff, String fm, int fc) {
    for (Iterator<ReductionRule> iterator = _multiReductionRules.iterator(); iterator.hasNext(); ) {
        ReductionRule mrr = (ReductionRule) iterator.next();
        Triplet triplet = mrr.getParent().getTriplet();
        if (triplet.getFaultFamily().compareTo(ff) == 0 && triplet.getFaultMember().compareTo(fm) == 0 && triplet.getFaultCode().intValue() == fc) {
            return mrr;
        }
    }
    return null;
}
Also used : Triplet(cern.laser.business.data.Triplet)

Aggregations

Triplet (cern.laser.business.data.Triplet)20 AlarmImpl (cern.laser.business.data.AlarmImpl)8 Alarm (cern.laser.business.data.Alarm)6 Location (cern.laser.business.data.Location)6 ResponsiblePerson (cern.laser.business.data.ResponsiblePerson)6 Source (cern.laser.business.data.Source)6 ReductionRule (cl.utfsm.acs.acg.core.ReductionRule)5 HashSet (java.util.HashSet)5 TreeItem (org.eclipse.swt.widgets.TreeItem)5 FaultCode (alma.acs.alarmsystem.generated.FaultCode)3 FaultFamily (alma.acs.alarmsystem.generated.FaultFamily)3 FaultMember (alma.acs.alarmsystem.generated.FaultMember)3 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 IllegalOperationException (cl.utfsm.acs.acg.core.IllegalOperationException)3 MalformedURLException (java.net.MalformedURLException)3 Timestamp (java.sql.Timestamp)3 ArrayList (java.util.ArrayList)3