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;
}
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());
}
}
}
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;
}
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());
}
}
}
}
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;
}
Aggregations