Search in sources :

Example 1 with ConfigurationProperty

use of alma.alarmsystem.alarmmessage.generated.ConfigurationProperty 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 2 with ConfigurationProperty

use of alma.alarmsystem.alarmmessage.generated.ConfigurationProperty 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 3 with ConfigurationProperty

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

the class AlarmSystemManager method loadFromCDB.

public void loadFromCDB() {
    if (_acsInfo == null || _daoManager == null)
        throw new IllegalStateException("The manager connection has not been initialized yet");
    _configurationProperty.clear();
    if (_alarmSystemDAO == null)
        _alarmSystemDAO = _daoManager.getAlarmSystemDAO();
    /* Make sure that we have all the managers here... */
    getAlarmManager();
    getSourceManager();
    getCategoryManager();
    getReductionManager();
    /* Now let them load their stuff from the DAOs */
    List<ConfigurationProperty> cps = _alarmSystemDAO.loadConfigurations();
    for (ConfigurationProperty cp : cps) {
        _configurationProperty.put(cp.getName(), cp.getContent());
    }
    _alarmManager.loadFromCDB();
    _sourceManager.loadFromCDB();
    _categoryManager.loadFromCDB();
    _reductionManager.loadFromCDB();
}
Also used : ConfigurationProperty(alma.alarmsystem.alarmmessage.generated.ConfigurationProperty)

Example 4 with ConfigurationProperty

use of alma.alarmsystem.alarmmessage.generated.ConfigurationProperty 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 5 with ConfigurationProperty

use of alma.alarmsystem.alarmmessage.generated.ConfigurationProperty 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)

Aggregations

ConfigurationProperty (alma.alarmsystem.alarmmessage.generated.ConfigurationProperty)6 AlarmSystemConfiguration (alma.alarmsystem.alarmmessage.generated.AlarmSystemConfiguration)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