use of org.omg.CosPropertyService.Property in project ACS by ACS-Community.
the class ACSJMSMessage method findProperty.
/**
* Find a message's property in the IDL structure by name, creating it if
* doesn't exist and if so specified.
*
* @param name The name of the property to look for.
* @param create <code>true</code> if the property is to be created.
* @return The index of the property with the given name in the array.
* -1 if the property was not found.
*/
private int findProperty(String name, boolean create) {
// Find the property with the given name in the array.
for (int i = 0; i < this.entity.properties.length; ++i) {
if (name.equals(this.entity.properties[i].property_name)) {
return i;
}
}
// Not found, but we can create it.
if (create) {
Property[] newProperties = new Property[this.entity.properties.length + 1];
for (int i = 0; i < this.entity.properties.length; ++i) {
newProperties[i] = this.entity.properties[i];
}
//newProperties[newProperties.length-1] = new Property(name, alma.acs.container.corba.AcsCorba.getAcsCorba().getORB().create_any());
newProperties[newProperties.length - 1] = new Property(name, containerServices.getAdvancedContainerServices().getAny());
this.entity.properties = newProperties;
return newProperties.length - 1;
}
// Not found, but we can't create it.
return -1;
}
use of org.omg.CosPropertyService.Property in project ACS by ACS-Community.
the class LaserComponent method submitAlarm.
/**
* IDL method: submit an alarm without.
* <P>
* Build a message to sent to the {@link AlarmMessageProcessorImpl#process(Message)}.
*
* @param triplet The triplet of the alarm
* @param active if <code>true</code> the alarm is active
* @param sourceHostName The name of the host of the source
* @param timestamp The timestamp of the source
* @param alarmProperties Additional user-defined properties of the alarm
*/
public synchronized void submitAlarm(Triplet triplet, boolean active, String sourceHostName, String sourceName, long timestamp, Property[] alarmProperties) throws BadParameterEx, UnexpectedExceptionEx {
cern.laser.source.alarmsysteminterface.impl.message.FaultState fs = new cern.laser.source.alarmsysteminterface.impl.message.FaultState();
fs.setCode(triplet.faultCode);
fs.setMember(triplet.faultMember);
fs.setFamily(triplet.faultFamily);
logger.log(AcsLogLevel.DEBUG, "Submitting alarm <" + triplet.faultFamily + ", " + triplet.faultMember + ", " + triplet.faultCode + "> active=" + active);
// Properties
cern.laser.source.alarmsysteminterface.impl.message.Properties props = new cern.laser.source.alarmsysteminterface.impl.message.Properties();
if (alarmProperties != null) {
for (Property p : alarmProperties) {
cern.laser.source.alarmsysteminterface.impl.message.Property propToAdd = new cern.laser.source.alarmsysteminterface.impl.message.Property();
propToAdd.setName(p.property_name);
propToAdd.setValue(p.property_value.toString());
props.addProperty(propToAdd);
}
}
fs.setUserProperties(props);
// Timestamp
long javaTime = UTCUtility.utcOmgToJava(timestamp);
long seconds = javaTime / 1000;
long milliseconds = javaTime % 1000;
String tStamp = IsoDateFormat.formatCurrentDate();
fs.setUserTimestamp(tStamp);
// Descriptor
if (active) {
fs.setDescriptor(ACSFaultState.ACTIVE);
} else {
fs.setDescriptor(ACSFaultState.TERMINATE);
}
// Build the message
TextMessage message;
try {
message = buildMessage(fs, sourceHostName, sourceName);
} catch (IllegalArgumentException ie) {
AcsJBadParameterEx ex = new AcsJBadParameterEx(ie);
throw ex.toBadParameterEx();
} catch (Throwable t) {
AcsJUnexpectedExceptionEx ex = new AcsJUnexpectedExceptionEx(t);
throw ex.toUnexpectedExceptionEx();
}
// Inject the message
try {
onMessage(message.getText());
} catch (Throwable t) {
AcsJUnexpectedExceptionEx ex = new AcsJUnexpectedExceptionEx(t);
throw ex.toUnexpectedExceptionEx();
}
}
use of org.omg.CosPropertyService.Property in project ACS by ACS-Community.
the class LaserComponent method fromBusinessAlarm.
/**
* Helper method which converts EJB business Alarm to CORBA Alarm structure.
* @param alarm
* @return
*/
private Alarm fromBusinessAlarm(cern.laser.business.data.Alarm alarm) {
cern.laser.business.data.Triplet bt = alarm.getTriplet();
cern.laser.business.data.Location bl = alarm.getLocation();
if (bl.getBuilding() == null) {
bl.setBuilding(new Building("", "", 1, ""));
}
cern.laser.business.data.Status bs = alarm.getStatus();
// Build the properties
Property[] props;
if (alarm.getStatus().getProperties() != null) {
props = new Property[alarm.getStatus().getProperties().size()];
Set keys = alarm.getStatus().getProperties().keySet();
int t = 0;
for (Object key : keys) {
String name = (String) key;
String value = alarm.getStatus().getProperties().getProperty(name);
Any any = corbaServer.getORB().create_any();
any.insert_string(value);
props[t++] = new Property(name, any);
}
} else {
props = new Property[0];
}
Alarm newAlarm = new Alarm(alarm.getAlarmId(), new Triplet(bt.getFaultFamily(), bt.getFaultMember(), bt.getFaultCode().intValue()), getString(alarm.getSystemName()), getString(alarm.getIdentifier()), getString(alarm.getProblemDescription()), alarm.getPriority().intValue(), getString(alarm.getCause()), getString(alarm.getAction()), getString(alarm.getConsequence()), fromBusinessSource(alarm.getSource()), getString(alarm.getHelpURL().toExternalForm()), getString(alarm.getPiquetGSM()), getString(alarm.getPiquetEmail()), fromBusinessResponsiblePerson(alarm.getResponsiblePerson()), new Location(bl.getLocationId(), bl.getFloor(), bl.getRoom(), bl.getPosition(), bl.getMnemonic(), bl.getBuilding().getBuildingNumber(), bl.getBuilding().getSite(), bl.getBuilding().getZone().intValue(), bl.getBuilding().getMap()), fromBusinessCategoryCollection(alarm.getCategories()), new Status(bs.getActive().booleanValue(), bs.getMasked().booleanValue(), bs.getReduced().booleanValue(), new Timestamp(bs.getSourceTimestamp().getTime(), bs.getSourceTimestamp().getNanos()), bs.getSourceHostname(), new Timestamp(bs.getUserTimestamp().getTime(), bs.getUserTimestamp().getNanos()), new Timestamp(bs.getSystemTimestamp().getTime(), bs.getSystemTimestamp().getNanos()), props), alarm.getInstant().booleanValue(), alarm.hasNodeParents(), alarm.hasMultiplicityParents(), alarm.hasNodeChildren(), alarm.hasMultiplicityChildren());
return newAlarm;
}
use of org.omg.CosPropertyService.Property in project ACS by ACS-Community.
the class CharacteristicModelImpl method get_all_characteristics.
/**
* @see alma.ACS.CharacteristicModelOperations#get_all_characteristics()
*/
public PropertySet get_all_characteristics() {
String[] allSeq;
try {
if (prefix == "")
allSeq = dao.get_string_seq("");
else
allSeq = dao.get_string_seq(prefix);
Property[] p = new Property[allSeq.length];
for (int i = 0; i < allSeq.length; i++) {
Any a = get_characteristic_by_name(allSeq[i]);
p[i] = new Property(allSeq[i], a);
}
//dangerous methods!!
ORB orb = m_container.getAdvancedContainerServices().getORB();
POA rootpoa = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
rootpoa.the_POAManager().activate();
PropertySetImpl psetImpl = new PropertySetImpl(p);
PropertySetPOATie psetTie = new PropertySetPOATie(psetImpl, rootpoa);
return psetTie._this(orb);
} catch (CDBFieldDoesNotExistEx e) {
} catch (WrongCDBDataTypeEx e) {
} catch (NoSuchCharacteristic e) {
} catch (MultipleExceptions e) {
} catch (InvalidName e) {
} catch (AdapterInactive e) {
} catch (NullPointerException e) {
System.out.println(e);
}
throw new NO_IMPLEMENT();
}
Aggregations