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