Search in sources :

Example 1 with AlarmSystemConfiguration

use of alma.alarmsystem.alarmmessage.generated.AlarmSystemConfiguration in project ACS by ACS-Community.

the class AlarmSystemManager method saveToCDB.

public void saveToCDB() {
    if (_acsInfo == null || _daoManager == null)
        throw new IllegalStateException("The manager connection has not been initialized yet");
    /* Make sure that we have all the managers here... */
    if (_alarmSystemDAO == null)
        _alarmSystemDAO = _daoManager.getAlarmSystemDAO();
    getAlarmManager();
    getSourceManager();
    getCategoryManager();
    getReductionManager();
    /* Backup the CDB */
    _daoManager.backupCDB();
    /* Now let them save their stuff through the DAOs */
    Set<String> keys = _configurationProperty.keySet();
    String[] cps = new String[keys.size()];
    keys.toArray(cps);
    AlarmSystemConfiguration asc = new AlarmSystemConfiguration();
    for (String sCP : cps) {
        ConfigurationProperty cp = new ConfigurationProperty();
        cp.setName(sCP);
        cp.setContent(_configurationProperty.get(sCP));
        asc.addConfigurationProperty(cp);
    }
    _alarmSystemDAO.flushConfiguration(asc);
    _alarmManager.saveToCDB();
    //_sourceManager.saveToCDB();
    _categoryManager.saveToCDB();
    _reductionManager.saveToCDB();
}
Also used : ConfigurationProperty(alma.alarmsystem.alarmmessage.generated.ConfigurationProperty) AlarmSystemConfiguration(alma.alarmsystem.alarmmessage.generated.AlarmSystemConfiguration)

Example 2 with AlarmSystemConfiguration

use of alma.alarmsystem.alarmmessage.generated.AlarmSystemConfiguration in project ACS by ACS-Community.

the class AlarmSystemCorbaServer method getAlarmSystemType.

/**
	 * Query the CDB to understand which one between ACS and CERN implementation
	 * has to be used
	 *  
	 * @return <code>true</code> if ACS implementation must be used
	 * @throws Exception In case of error
	 */
private boolean getAlarmSystemType() throws Exception {
    DAL dal = getCDB();
    String str = dal.get_DAO("Alarms/Administrative/AlarmSystemConfiguration");
    StringReader strReader = new StringReader(str);
    AlarmSystemConfiguration configuration;
    try {
        configuration = AlarmSystemConfiguration.unmarshalAlarmSystemConfiguration(strReader);
    } catch (Throwable t) {
        m_logger.log(AcsLogLevel.ERROR, "Error parsing alarm configuration: using ACS alarm implementation");
        return true;
    }
    for (int propNum = 0; propNum < configuration.getConfigurationPropertyCount(); propNum++) {
        ConfigurationProperty property = configuration.getConfigurationProperty(propNum);
        if (property.getName().equalsIgnoreCase("Implementation")) {
            if (property.getContent().equalsIgnoreCase("CERN")) {
                return false;
            }
        }
    }
    return true;
}
Also used : ConfigurationProperty(alma.alarmsystem.alarmmessage.generated.ConfigurationProperty) StringReader(java.io.StringReader) AlarmSystemConfiguration(alma.alarmsystem.alarmmessage.generated.AlarmSystemConfiguration) DAL(com.cosylab.CDB.DAL)

Example 3 with AlarmSystemConfiguration

use of alma.alarmsystem.alarmmessage.generated.AlarmSystemConfiguration in project ACS by ACS-Community.

the class ACSAlarmSystemDAOImpl method loadConfigurations.

public List<ConfigurationProperty> loadConfigurations() {
    configs.clear();
    AlarmSystemConfiguration asc = getConfiguration();
    List<ConfigurationProperty> cf = new ArrayList<ConfigurationProperty>();
    ConfigurationProperty[] cps = asc.getConfigurationProperty();
    for (ConfigurationProperty cp : cps) {
        configs.put(cp.getName(), cp.getContent());
        cf.add(cp);
    }
    return cf;
}
Also used : ConfigurationProperty(alma.alarmsystem.alarmmessage.generated.ConfigurationProperty) AlarmSystemConfiguration(alma.alarmsystem.alarmmessage.generated.AlarmSystemConfiguration) ArrayList(java.util.ArrayList)

Example 4 with AlarmSystemConfiguration

use of alma.alarmsystem.alarmmessage.generated.AlarmSystemConfiguration in project ACS by ACS-Community.

the class ACSAlarmSystemDAOImpl method getConfiguration.

public AlarmSystemConfiguration getConfiguration() {
    if (conf == null)
        throw new IllegalStateException("null configuration accessor");
    AlarmSystemConfiguration asc;
    String xml;
    try {
        xml = conf.getConfiguration(ALARM_SYSTEM_CONFIGURATION_PATH);
    } catch (CDBRecordDoesNotExistEx e) {
        asc = new AlarmSystemConfiguration();
        ConfigurationProperty cp = new ConfigurationProperty();
        cp.setName("Implementation");
        cp.setContent("ACS");
        asc.addConfigurationProperty(cp);
        return asc;
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
    StringReader FFReader = new StringReader(xml);
    Unmarshaller FF_unmarshaller = new Unmarshaller(AlarmSystemConfiguration.class);
    FF_unmarshaller.setValidation(false);
    try {
        asc = (AlarmSystemConfiguration) FF_unmarshaller.unmarshal(FFReader);
    } catch (MarshalException e) {
        e.printStackTrace();
        return null;
    } catch (ValidationException e) {
        e.printStackTrace();
        return null;
    }
    try {
        asc.validate();
    } catch (ValidationException e) {
        e.printStackTrace();
    }
    return asc;
}
Also used : ConfigurationProperty(alma.alarmsystem.alarmmessage.generated.ConfigurationProperty) MarshalException(org.exolab.castor.xml.MarshalException) ValidationException(org.exolab.castor.xml.ValidationException) AlarmSystemConfiguration(alma.alarmsystem.alarmmessage.generated.AlarmSystemConfiguration) StringReader(java.io.StringReader) Unmarshaller(org.exolab.castor.xml.Unmarshaller) IOException(java.io.IOException) ValidationException(org.exolab.castor.xml.ValidationException) MarshalException(org.exolab.castor.xml.MarshalException) CDBRecordDoesNotExistEx(alma.cdbErrType.CDBRecordDoesNotExistEx)

Example 5 with AlarmSystemConfiguration

use of alma.alarmsystem.alarmmessage.generated.AlarmSystemConfiguration in project ACS by ACS-Community.

the class ACSAlarmSystemDAOImplTest method testGetConfiguration.

public void testGetConfiguration() {
    AlarmSystemConfiguration asc = _alarmSystemDAO.getConfiguration();
    ConfigurationProperty[] cps = asc.getConfigurationProperty();
    for (ConfigurationProperty cp : cps) {
        System.out.println(cp.getContent());
    }
    List<ConfigurationProperty> cpsL = _alarmSystemDAO.loadConfigurations();
    for (ConfigurationProperty cp : cpsL) {
        System.out.println(cp.getName() + "_" + cp.getContent());
    }
}
Also used : ConfigurationProperty(alma.alarmsystem.alarmmessage.generated.ConfigurationProperty) AlarmSystemConfiguration(alma.alarmsystem.alarmmessage.generated.AlarmSystemConfiguration)

Aggregations

AlarmSystemConfiguration (alma.alarmsystem.alarmmessage.generated.AlarmSystemConfiguration)5 ConfigurationProperty (alma.alarmsystem.alarmmessage.generated.ConfigurationProperty)5 StringReader (java.io.StringReader)2 CDBRecordDoesNotExistEx (alma.cdbErrType.CDBRecordDoesNotExistEx)1 DAL (com.cosylab.CDB.DAL)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 MarshalException (org.exolab.castor.xml.MarshalException)1 Unmarshaller (org.exolab.castor.xml.Unmarshaller)1 ValidationException (org.exolab.castor.xml.ValidationException)1