Search in sources :

Example 21 with Category

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

the class ACSCategoryDAOImpl method updateCategory.

public void updateCategory(Category category) {
    Integer id = category.getCategoryId();
    if (id == null)
        throw new IllegalStateException();
    Category previous = categories.get(id);
    // path may have changed
    catPathToCategory.values().remove(previous);
    categories.put(id, category);
    if (category.getPath() != null)
        catPathToCategory.put(category.getPath(), category);
}
Also used : Category(cern.laser.business.data.Category)

Example 22 with Category

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

the class ACSCategoryDAOImpl method assignCategoryOfCoreAlarms.

/**
	 * Assign core alarms to the root category.
	 * 
	 * @see LaserCoreAlarms
	 * @see LaserCoreFaultState
	 * @see LaserCoreFaultCodes
	 */
private void assignCategoryOfCoreAlarms() {
    String[] coreIds = LaserCoreFaultState.getCoreAlarmIds();
    Category rootCategory = getCategoryByPath("ROOT");
    assignCategoryToAlarms(rootCategory, LaserCoreFaultState.FaultFamily);
}
Also used : Category(cern.laser.business.data.Category)

Example 23 with Category

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

the class ACSCategoryDAOImpl method getChildren.

public Integer[] getChildren(Integer parentId) {
    int pid = parentId.intValue();
    CategoryImpl cat = (CategoryImpl) getCategory(parentId);
    if (cat == null)
        return null;
    ArrayList<Integer> result = new ArrayList<Integer>();
    Iterator<Category> i = categories.values().iterator();
    while (i.hasNext()) {
        Category c = i.next();
        // root categories have null parentId
        if (c.getParentId() != null && c.getParentId().intValue() == pid)
            result.add(c.getCategoryId());
    }
    Integer[] out = new Integer[result.size()];
    result.toArray(out);
    return out;
}
Also used : CategoryImpl(cern.laser.business.data.CategoryImpl) Category(cern.laser.business.data.Category) ArrayList(java.util.ArrayList)

Example 24 with Category

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

the class ACSCategoryDAOImpl method assignCategoryToAlarms.

/**
	 * Assign the category to the all the alarms of a given FaultFamily.
	 * 
	 * In the CDB each category has a list (eventually empty) of FaultFamily.
	 * If a FaultFamily appear in the definition of a Category then add
	 * such category to all the alarms of such FF.
	 *   
	 *  @param category The category to assign to the alarms
	 *  @param FF The fault family of the alarms to assign the category to
	 */
private void assignCategoryToAlarms(Category category, String FF) {
    if (category == null) {
        throw new IllegalArgumentException("Invalid null category");
    }
    if (FF == null) {
        throw new IllegalArgumentException("Invalid null fault family");
    }
    String[] alarmIDs = ((ACSAlarmDAOImpl) alarmDao).getAllAlarmIDs();
    for (String id : alarmIDs) {
        Alarm alarm = alarmDao.getAlarm(id);
        if (alarm == null) {
            logger.log(AcsLogLevel.WARNING, "Got a null alarm for ID=" + id);
            continue;
        }
        if (alarm.getTriplet().getFaultFamily().equals(FF)) {
            Collection<Category> alarmCategories = alarm.getCategories();
            if (!alarmCategories.contains(category)) {
                alarmCategories.add(category);
                logger.log(AcsLogLevel.DEBUG, "Category " + category.getName() + " assigned to alarm " + alarm.getAlarmId());
            }
        }
    }
}
Also used : Category(cern.laser.business.data.Category) Alarm(cern.laser.business.data.Alarm)

Example 25 with Category

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

the class ACSCategoryDAOImpl method deleteCategory.

public void deleteCategory(Category category) {
    Integer id = category.getCategoryId();
    if (id == null)
        throw new IllegalStateException();
    Category previous = categories.get(id);
    categories.remove(id);
    // this one was in catPath, so remove that one instead
    // have to use values(), because the path may have changed,
    // but mapping didn't
    catPathToCategory.values().remove(previous);
}
Also used : Category(cern.laser.business.data.Category)

Aggregations

Category (cern.laser.business.data.Category)47 Alarm (cern.laser.business.data.Alarm)16 CategoryImpl (cern.laser.business.data.CategoryImpl)14 HashSet (java.util.HashSet)9 AdminUser (cern.laser.business.data.AdminUser)8 LaserDefinitionNotValidException (cern.laser.business.definition.LaserDefinitionNotValidException)8 LaserDefinitionDuplicationException (cern.laser.business.definition.LaserDefinitionDuplicationException)7 LaserDefinitionNotAllowedException (cern.laser.business.definition.LaserDefinitionNotAllowedException)7 LaserDefinitionNotFoundException (cern.laser.business.definition.LaserDefinitionNotFoundException)7 CategoryDefinition (alma.alarmsystem.alarmmessage.generated.CategoryDefinition)6 LaserObjectNotFoundException (cern.laser.business.LaserObjectNotFoundException)6 AlarmCacheException (cern.laser.business.cache.AlarmCacheException)6 Source (cern.laser.business.data.Source)6 ResponsiblePerson (cern.laser.business.data.ResponsiblePerson)5 AlarmCategoryDefinitions (alma.alarmsystem.alarmmessage.generated.AlarmCategoryDefinitions)4 AlarmCategoryLinkDefinitionListType (alma.alarmsystem.alarmmessage.generated.AlarmCategoryLinkDefinitionListType)4 AlarmCategoryLinkType (alma.alarmsystem.alarmmessage.generated.AlarmCategoryLinkType)4 AlarmDefinition (alma.alarmsystem.alarmmessage.generated.AlarmDefinition)4 AlarmImpl (cern.laser.business.data.AlarmImpl)4 LaserDefinitionException (cern.laser.business.definition.LaserDefinitionException)4