Search in sources :

Example 1 with Property

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;
}
Also used : Property(org.omg.CosPropertyService.Property)

Example 2 with Property

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();
    }
}
Also used : AcsJBadParameterEx(alma.ACSErrTypeCommon.wrappers.AcsJBadParameterEx) ACSFaultState(alma.alarmsystem.source.ACSFaultState) FaultState(cern.laser.source.alarmsysteminterface.impl.message.FaultState) LaserCoreFaultState(alma.alarmsystem.core.alarms.LaserCoreFaultState) FaultState(cern.laser.source.alarmsysteminterface.impl.message.FaultState) AcsJUnexpectedExceptionEx(alma.ACSErrTypeCommon.wrappers.AcsJUnexpectedExceptionEx) Property(org.omg.CosPropertyService.Property) ACSJMSTextMessage(com.cosylab.acs.jms.ACSJMSTextMessage) TextMessage(javax.jms.TextMessage)

Example 3 with Property

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;
}
Also used : Building(cern.laser.business.data.Building) Status(alma.alarmsystem.Status) Set(java.util.Set) Triplet(alma.alarmsystem.Triplet) Any(org.omg.CORBA.Any) Timestamp(alma.alarmsystem.Timestamp) Alarm(alma.alarmsystem.Alarm) Property(org.omg.CosPropertyService.Property) Location(alma.alarmsystem.Location)

Example 4 with Property

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();
}
Also used : NO_IMPLEMENT(org.omg.CORBA.NO_IMPLEMENT) POA(org.omg.PortableServer.POA) NoSuchCharacteristic(alma.ACS.NoSuchCharacteristic) AdapterInactive(org.omg.PortableServer.POAManagerPackage.AdapterInactive) Any(org.omg.CORBA.Any) PropertySetImpl(alma.ACS.jbaci.PropertySetImpl) PropertySetPOATie(org.omg.CosPropertyService.PropertySetPOATie) InvalidName(org.omg.CORBA.ORBPackage.InvalidName) CDBFieldDoesNotExistEx(alma.cdbErrType.CDBFieldDoesNotExistEx) MultipleExceptions(org.omg.CosPropertyService.MultipleExceptions) Property(org.omg.CosPropertyService.Property) ORB(org.omg.CORBA.ORB) WrongCDBDataTypeEx(alma.cdbErrType.WrongCDBDataTypeEx)

Aggregations

Property (org.omg.CosPropertyService.Property)4 Any (org.omg.CORBA.Any)2 NoSuchCharacteristic (alma.ACS.NoSuchCharacteristic)1 PropertySetImpl (alma.ACS.jbaci.PropertySetImpl)1 AcsJBadParameterEx (alma.ACSErrTypeCommon.wrappers.AcsJBadParameterEx)1 AcsJUnexpectedExceptionEx (alma.ACSErrTypeCommon.wrappers.AcsJUnexpectedExceptionEx)1 Alarm (alma.alarmsystem.Alarm)1 Location (alma.alarmsystem.Location)1 Status (alma.alarmsystem.Status)1 Timestamp (alma.alarmsystem.Timestamp)1 Triplet (alma.alarmsystem.Triplet)1 LaserCoreFaultState (alma.alarmsystem.core.alarms.LaserCoreFaultState)1 ACSFaultState (alma.alarmsystem.source.ACSFaultState)1 CDBFieldDoesNotExistEx (alma.cdbErrType.CDBFieldDoesNotExistEx)1 WrongCDBDataTypeEx (alma.cdbErrType.WrongCDBDataTypeEx)1 Building (cern.laser.business.data.Building)1 FaultState (cern.laser.source.alarmsysteminterface.impl.message.FaultState)1 ACSJMSTextMessage (com.cosylab.acs.jms.ACSJMSTextMessage)1 Set (java.util.Set)1 TextMessage (javax.jms.TextMessage)1