コード例 #1
0
 def _createComplexJavaProp(self, prop):
     '''
     Create a javaprop that may or may not be complex.
     '''
     javaprop = self.mapProperty(prop)
     javaprop['isComplex'] = prop.isComplex()
     if prop.isComplex():
         javatype = properties.mapComplexType(prop.type())
         javaprop['javaclass'] = 'Complex'+self.javaClass(prop.type())
         javaprop['javatype'] = 'CF.' + javatype
     else:
         javatype = self.javaType(prop.type())
         javaprop['javaclass'] = self.javaClass(prop.type())
         javaprop['javatype'] = java.boxedType(javatype)
     return javaprop, javatype
コード例 #2
0
 def _createComplexJavaProp(self, prop):
     '''
     Create a javaprop that may or may not be complex.
     '''
     javaprop = self.mapProperty(prop)
     javaprop['isComplex'] = prop.isComplex()
     if prop.isComplex():
         javatype = properties.mapComplexType(prop.type())
         javaprop['javaclass'] = 'Complex' + self.javaClass(prop.type())
         javaprop['javatype'] = 'CF.' + javatype
     else:
         javatype = self.javaType(prop.type())
         javaprop['javaclass'] = self.javaClass(prop.type())
         javaprop['javatype'] = java.boxedType(javatype)
     return javaprop, javatype
コード例 #3
0
ファイル: __init__.py プロジェクト: bdeeg08/framework-core
    def _getPropType(self, prop):
        '''
        Returns the property type.

        If the complex flag is set to true, the type is converted 
        from the primitive type (e.g., long) to the complex type 
        (e.g., complexLong) to support downstream processing.

        '''

        propType = prop.get_type()

        complex = prop.get_complex()
        if complex.lower() == "true":
            propType = _properties.mapComplexType(propType)
        return propType
コード例 #4
0
    def getPropertySet(self, kinds=("configure","property",), \
                             modes=("readwrite", "writeonly", "readonly"), \
                             action="external", \
                             includeNil=True,
                             commandline=False):
        """
        A useful utility function that extracts specified property types from
        the PRF file and turns them into a CF.PropertySet
        """
        propertySet = []

        # Simples
        if self.prf != None:
            for prop in self.prf.get_simple():
                if self.isMatch(prop, modes, kinds, (action, )):
                    if prop.get_value() is not None:
                        if prop.complex.lower() == "true":
                            type = mapComplexType(prop.get_type())
                            value = stringToComplex(prop.get_value(), type)
                        else:
                            type = prop.get_type()
                            value = prop.get_value()
                        dt = properties.to_tc_value(value, type)
                    elif not includeNil:
                        continue
                    else:
                        dt = any.to_any(None)
                    p = CF.DataType(id=str(prop.get_id()), value=dt)
                    propertySet.append(p)

            # Simple Sequences
            for prop in self.prf.get_simplesequence():
                if self.isMatch(prop, modes, kinds, (action, )):
                    if prop.get_values() is not None:
                        seq = []
                        if prop.complex.lower() == "true":
                            type = mapComplexType(prop.get_type())
                            for v in prop.get_values().get_value():
                                seq.append(stringToComplex(v, type))
                            expectedType = properties.getTypeCode(type)
                            expectedTypeCode = tcInternal.createTypeCode(
                                (tcInternal.tv_sequence, expectedType._d, 0))
                            dt = CORBA.Any(expectedTypeCode, [
                                properties._convertComplexToCFComplex(
                                    item, type) for item in seq
                            ])
                        else:
                            type = prop.get_type()
                            for v in prop.get_values().get_value():
                                value = v
                                seq.append(properties.to_pyvalue(value, type))
                            dt = any.to_any(seq)
                    elif not includeNil:
                        continue
                    else:
                        dt = any.to_any(None)
                    p = CF.DataType(id=str(prop.get_id()), value=dt)
                    propertySet.append(p)

            # Structures
            for prop in self.prf.get_struct():
                if self.isMatch(prop, modes, kinds, (action, )):
                    if (prop.get_simple()
                            is not None) or (prop.get_simplesequence()
                                             is not None):
                        fields = []
                        hasValue = False
                        if prop.get_simple() is not None:
                            for p in prop.get_simple():
                                if p.get_value() is not None:
                                    hasValue = True
                                dt = properties.to_tc_value(
                                    p.get_value(), p.get_type())
                                fields.append(
                                    CF.DataType(id=str(p.get_id()), value=dt))
                        if prop.get_simplesequence() is not None:
                            for p in prop.get_simplesequence():
                                if p.get_values() is not None:
                                    hasValue = True
                                dt = properties.to_tc_value(
                                    p.get_values(), p.get_type())
                                fields.append(
                                    CF.DataType(id=str(p.get_id()), value=dt))
                        if not hasValue and not includeNil:
                            continue
                        dt = any.to_any(fields)
                    else:
                        dt = any.to_any(None)
                    p = CF.DataType(id=str(prop.get_id()), value=dt)
                    propertySet.append(p)

            # Struct Sequence
            for prop in self.prf.get_structsequence():
                if self.isMatch(prop, modes, kinds, (action, )):
                    baseProp = []
                    if prop.get_struct() != None:
                        fields = []
                        for internal_prop in prop.get_struct().get_simple():
                            fields.append(
                                CF.DataType(id=str(internal_prop.get_id()),
                                            value=any.to_any(None)))
                        for internal_prop in prop.get_struct(
                        ).get_simplesequence():
                            fields.append(
                                CF.DataType(id=str(internal_prop.get_id()),
                                            value=any.to_any(None)))
                    for val in prop.get_structvalue():
                        baseProp.append(copy.deepcopy(fields))
                        for entry in val.get_simpleref():
                            val_type = None
                            for internal_prop in prop.get_struct().get_simple(
                            ):
                                if str(internal_prop.get_id()) == entry.refid:
                                    val_type = internal_prop.get_type()
                            for subfield in baseProp[-1]:
                                if subfield.id == entry.refid:
                                    subfield.value = properties.to_tc_value(
                                        entry.get_value(), val_type)
                        for entry in val.get_simplesequenceref():
                            val_type = None
                            for internal_prop in prop.get_struct(
                            ).get_simplesequence():
                                if str(internal_prop.get_id()) == entry.refid:
                                    val_type = internal_prop.get_type()
                            for subfield in baseProp[-1]:
                                if subfield.id == entry.refid:
                                    subfield.value = properties.to_tc_value(
                                        entry.get_values(), val_type)
                    anybp = []
                    for bp in baseProp:
                        anybp.append(properties.props_to_any(bp))
                    p = CF.DataType(id=str(prop.get_id()),
                                    value=any.to_any(anybp))
                    propertySet.append(p)

        return propertySet
コード例 #5
0
    def getPropertySet(self, kinds=("configure",), \
                             modes=("readwrite", "writeonly", "readonly"), \
                             action="external", \
                             includeNil=True):
        """
        A useful utility function that extracts specified property types from
        the PRF file and turns them into a CF.PropertySet
        """
        propertySet = []

        # Simples
        for prop in self.prf.get_simple():
            if self.isMatch(prop, modes, kinds, (action,)): 
                if prop.get_value() is not None:    
                    if prop.complex.lower() == "true":
                        type = mapComplexType(prop.get_type())
                        value = stringToComplex(prop.get_value(), type)
                    else:
                        type = prop.get_type()
                        value = prop.get_value()
                    dt = properties.to_tc_value(value, type)
                elif not includeNil:
                    continue
                else:
                    dt = any.to_any(None)
                p = CF.DataType(id=str(prop.get_id()), value=dt)
                propertySet.append(p)

        # Simple Sequences
        for prop in self.prf.get_simplesequence():
            if self.isMatch(prop, modes, kinds, (action,)): 
                if prop.get_values() is not None:
                    seq = []
                    if prop.complex.lower() == "true":
                        type = mapComplexType(prop.get_type())
                        for v in prop.get_values().get_value():
                            seq.append(stringToComplex(v, type))
                        expectedType = properties.getTypeCode(type)
                        expectedTypeCode = tcInternal.createTypeCode(
                            (tcInternal.tv_sequence, expectedType._d, 0))
                        dt = CORBA.Any(expectedTypeCode, 
                                       [properties._convertComplexToCFComplex(item, type) 
                                            for item in seq])
                    else:
                        type = prop.get_type()
                        for v in prop.get_values().get_value():
                            value = v
                            seq.append(properties.to_pyvalue(value, type))
                        dt = any.to_any(seq)
                elif not includeNil:
                    continue
                else:
                    dt = any.to_any(None)
                p = CF.DataType(id=str(prop.get_id()), value=dt)
                propertySet.append(p)

        # Structures
        for prop in self.prf.get_struct():
            if self.isMatch(prop, modes, kinds, (action,)): 
                if prop.get_simple() is not None:
                    fields = []
                    hasValue = False
                    for s in prop.get_simple():
                        if s.get_value() is not None:
                            hasValue = True
                        dt = properties.to_tc_value(s.get_value(), s.get_type())
                        fields.append(CF.DataType(id=str(s.get_id()), value=dt))
                    if not hasValue and not includeNil:
                        continue
                    dt = any.to_any(fields)
                else:
                    dt = any.to_any(None)
                p = CF.DataType(id=str(prop.get_id()), value=dt)
                propertySet.append(p)
        # Structures

        for prop in self.prf.get_structsequence():
            if self.isMatch(prop, modes, kinds, (action,)):
              baseProp = []
              if prop.get_struct() != None:
                fields = []
                for internal_prop in prop.get_struct().get_simple():
                    fields.append(CF.DataType(id=str(internal_prop.get_id()), value=any.to_any(None)))
              for val in prop.get_structvalue():
                baseProp.append(copy.deepcopy(fields))
                for entry in val.get_simpleref():
                  val_type = None
                  for internal_prop in prop.get_struct().get_simple():
                      if str(internal_prop.get_id()) == entry.refid:
                          val_type = internal_prop.get_type()
                  for subfield in baseProp[-1]:
                      if subfield.id == entry.refid:
                        subfield.value = properties.to_tc_value(entry.get_value(), val_type)
              anybp = []
              for bp in baseProp:
                  anybp.append(properties.props_to_any(bp))
              p = CF.DataType(id=str(prop.get_id()), value=any.to_any(anybp))
              propertySet.append(p)
        # Struct Sequence

        return propertySet