Search in sources :

Example 1 with Category

use of alma.alarmsystem.Category 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 2 with Category

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

the class TestAlarmService method testGetCategories.

/**
	 * Test AlarmSerrvice's getCategories
	 * 
	 * @throws Exception
	 */
public void testGetCategories() throws Exception {
    Category[] categories = alarmService.getCategories();
    assertNotNull(categories);
    // CAT1, CAT2 and ROOT
    assertEquals(3, categories.length);
    for (Category cat : categories) {
        if (!cat.name.equals("ROOT") && !cat.name.equals("CATEGORY1") && !cat.name.equals("CATEGORY2")) {
            throw new Exception("Inavlid name of category: " + cat.name);
        }
        assertEquals(cat.name, cat.path);
    }
}
Also used : Category(alma.alarmsystem.Category)

Example 3 with Category

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

the class CategoryClient method addCategories.

/**
	 * Add the categories to the configuration i.e. add the categories 
	 * the client wants to listen to
	 * 
	 * @param config The Configuration
	 * @param categories The categories to listen to
	 *                   If it is null, it adds all the categories returned
	 *                   by the alarm system component
	 * @throws Exception 
	 */
private void addCategories(Configuration config, Category[] categories) throws Exception {
    if (categories == null) {
        categories = alarm.getCategories();
    }
    if (categories.length == 0) {
        logger.log(AcsLogLevel.WARNING, "No categories to connect to");
        return;
    }
    Selection selection = config.getSelection();
    CategorySelection catSel = selection.createCategorySelection();
    for (Category cat : categories) {
        cern.laser.business.data.CategoryImpl businessCategory = new cern.laser.business.data.CategoryImpl(cat.categoryId, cat.name, cat.description, cat.path, cat.leaf);
        cern.laser.client.impl.data.CategoryImpl cImpl = new cern.laser.client.impl.data.CategoryImpl(businessCategory);
        catSel.add(cImpl);
    }
    selection.setCategorySelection(catSel);
}
Also used : CategoryImpl(cern.laser.business.data.CategoryImpl) CategorySelection(cern.laser.client.services.selection.CategorySelection) Category(alma.alarmsystem.Category) CategoryImpl(cern.laser.business.data.CategoryImpl) CategorySelection(cern.laser.client.services.selection.CategorySelection) Selection(cern.laser.client.services.selection.Selection)

Example 4 with Category

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

the class LaserComponent method fromBusinessCategoryCollection.

/**
	 * Helper method.
	 * @param categories
	 * @return
	 */
private static Category[] fromBusinessCategoryCollection(Collection categories) {
    if (categories == null)
        return new Category[0];
    Category[] retVal = new Category[categories.size()];
    int pos = 0;
    for (Iterator iter = categories.iterator(); iter.hasNext(); ) {
        cern.laser.business.data.Category category = (cern.laser.business.data.Category) iter.next();
        retVal[pos++] = fromBusinessCategory(category);
    }
    return retVal;
}
Also used : Category(alma.alarmsystem.Category) Iterator(java.util.Iterator)

Example 5 with Category

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

the class CategoryClient method connect.

/**
	 * Create the consumers for the passed categories
	 * 
	 *   
	 * @param categoriesToConnect The categories to connect to
	 */
public void connect(Category[] categoriesToConnect) throws Exception {
    if (categoriesToConnect == null || categoriesToConnect.length == 0) {
        contSvc.getLogger().log(AcsLogLevel.INFO, "No categories to connect to");
        return;
    }
    consumers = new CategorySubscriber[categoriesToConnect.length];
    int t = 0;
    Vector<String> failingConnections = new Vector<String>();
    for (Category category : categoriesToConnect) {
        try {
            consumers[t++] = new CategorySubscriber(contSvc, categoryRootTopic, category.path, this);
            contSvc.getLogger().log(AcsLogLevel.DEBUG, "Connected to " + categoryRootTopic + "." + category.path);
        } catch (Throwable throwable) {
            failingConnections.add("Error subscribing to " + categoryRootTopic + "." + category.path + ": " + throwable.getMessage());
        }
    }
    if (failingConnections.size() > 0) {
        System.err.println("Error connecting categories: ");
        for (String str : failingConnections) {
            System.err.println("\t" + str);
        }
        throw new Exception("Error connecting categories");
    }
}
Also used : Category(alma.alarmsystem.Category) CategorySubscriber(alma.acs.lasercore.test.stress.category.CategorySubscriber) Vector(java.util.Vector)

Aggregations

Category (alma.alarmsystem.Category)6 CategoryImpl (cern.laser.business.data.CategoryImpl)2 CategorySubscriber (alma.acs.lasercore.test.stress.category.CategorySubscriber)1 AlarmImpl (cern.laser.business.data.AlarmImpl)1 Building (cern.laser.business.data.Building)1 Location (cern.laser.business.data.Location)1 ResponsiblePerson (cern.laser.business.data.ResponsiblePerson)1 Source (cern.laser.business.data.Source)1 Status (cern.laser.business.data.Status)1 StatusImpl (cern.laser.business.data.StatusImpl)1 Triplet (cern.laser.business.data.Triplet)1 Alarm (cern.laser.client.data.Alarm)1 CategorySelection (cern.laser.client.services.selection.CategorySelection)1 Selection (cern.laser.client.services.selection.Selection)1 Timestamp (java.sql.Timestamp)1 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 Properties (java.util.Properties)1 Vector (java.util.Vector)1