Cancel
Showing results for 
Search instead for 
Did you mean: 

SOA: is it possible to get property names of given class or object type ?

Solution Partner Legend Solution Partner Legend
Solution Partner Legend
2 REPLIES

Re: SOA: is it possible to get property names of given class or object type ?

Siemens Legend Siemens Legend
Siemens Legend

You should be able to use the client meta model to get this information.

 

Something a bit like...

 

    private void dumpType(String typeName) {
        ClientMetaModel metaModel = connection.getClientMetaModel();
        List<Type> types = metaModel.getTypes(new String[]{typeName}, connection);
        for (Type type : types) {
            System.out.println(type.getName());
            Map<String, String> typeConstants = type.getConstants();
            for (String constant : new TreeSet<String>(typeConstants.keySet())) {
                System.out.println("    Constant: " + constant + " = " + typeConstants.get(constant));
            }
            Hashtable<String, PropertyDescription> propDescs = type.getPropDescs();
            for (String propName : new TreeSet<String>(propDescs.keySet())) {
                System.out.println("    " + propName);
                PropertyDescription propDesc = propDescs.get(propName);
                System.out.println("        Display:" + propDesc.getUiName());
                System.out.println("        FieldType " + fieldTypeToString(propDesc.getFieldType()));
                System.out.println("        ServerType " + serverTypeToString(propDesc.getServerType()));
                System.out.println("        ServerPropertyType " + serverPropertyTypeToString(propDesc.getServerPropertyType()));
                System.out.println("        ClientType " + clientPropTypeToString(propDesc.getType()));
                System.out.println("        CompoundType " + propDesc.getCompoundObjectType());
                System.out.println("        IsArray " + propDesc.isArray());
                System.out.println("        IsDisplayable " + propDesc.isDisplayable());
                System.out.println("        IsEnabled " + propDesc.isEnabled());
                System.out.println("        IsModifiable " + propDesc.isModifiable());
                System.out.println("        LOV " + safeGetLOVName(propDesc.getLovReference()));
            }
        }
    }

    private String safeGetLOVName(Lov lovReference) {
        if (lovReference == null)
            return "";
        LovInfo lovInfo = lovReference.getLovInfo();
        if (lovInfo == null)
            return "nullLovInfo";
        return lovInfo.getName();
    }

    private String serverTypeToString(int serverPropertyType) {
        String type = "*UNKNOWN*";
        switch(serverPropertyType) {
            case PropertyDescription.SERVER_PROP_char :
                type = "char";
                break;
            case PropertyDescription.SERVER_PROP_date :
                type = "date";
                break;
            case PropertyDescription.SERVER_PROP_double :
                type = "double";
                break;
            case PropertyDescription.SERVER_PROP_external_reference :
                type = "ExternalReference";
                break;
            case PropertyDescription.SERVER_PROP_float :
                type = "float";
                break;
            case PropertyDescription.SERVER_PROP_int :
                type = "int";
                break;
            case PropertyDescription.SERVER_PROP_logical :
                type = "logical";
                break;
            case PropertyDescription.SERVER_PROP_note :
                type = "note";
                break;
            case PropertyDescription.SERVER_PROP_short :
                type = "short";
                break;
            case PropertyDescription.SERVER_PROP_string :
                type = "string";
                break;
            case PropertyDescription.SERVER_PROP_typed_reference :
                type = "TypedReference";
                break;
            case PropertyDescription.SERVER_PROP_typed_relation :
                type = "TypedRelation";
                break;
            case PropertyDescription.SERVER_PROP_untyped :
                type = "untyped";
                break;
            case PropertyDescription.SERVER_PROP_untyped_reference :
                type = "UntypedReference";
                break;
            case PropertyDescription.SERVER_PROP_untyped_relation :
                type = "UntypedRelation";
                break;
        }
        return type;
    }

    private String serverPropertyTypeToString(int serverPropType) {
        String type = "*UNKNOWN*";
        switch (serverPropType) {
            case PropertyDescription.PROPERTY_TYPE_UNKNOWN :
                type = "Unknown";
                break;
            case PropertyDescription.PROPERTY_TYPE_POM_ATTRIBUTE :
                type = "POM_Attribute";
                break;
            case PropertyDescription.PROPERTY_TYPE_POM_REFERENCE :
                type = "POM_Reference";
                break;
            case PropertyDescription.PROPERTY_TYPE_IMAN_RELATION :
                type = "IMAN_Relation";
                break;
            case PropertyDescription.PROPERTY_TYPE_PROP_FROM_ANOTHER_TYPE :
                type = "PropFromOtherType";
                break;
            case PropertyDescription.PROPERTY_TYPE_COMPUTED :
                type = "Computed";
                break;
            case PropertyDescription.PROPERTY_TYPE_SOURCE_PROPERTY :
                type = "SourceProperty";
                break;
        }
        return type;
    }

    private String fieldTypeToString(int fieldType) {
        String type = "*UNKNOWN*";
        switch (fieldType) {
            case PropertyDescription.FIELD_TYPE_UNKNOWN :
                type = "Unknown";
                break;
            case PropertyDescription.FIELD_TYPE_SIMPLE :
                type = "Simple";
                break;
            case PropertyDescription.FIELD_TYPE_COMPOND_OBJECT :
                type = "CompoundObject";
                break;
        }
        return type;
    }

    private String clientPropTypeToString(int fieldType) {
        String type = "*UNKNOWN*";
        switch (fieldType) {
            case PropertyDescription.CLIENT_PROP_TYPE_char :
                type = "char";
                break;
            case PropertyDescription.CLIENT_PROP_TYPE_date :
                type = "date";
                break;
            case PropertyDescription.CLIENT_PROP_TYPE_double :
                type = "double";
                break;
            case PropertyDescription.CLIENT_PROP_TYPE_float :
                type = "float";
                break;
            case PropertyDescription.CLIENT_PROP_TYPE_int :
                type = "int";
                break;
            case PropertyDescription.CLIENT_PROP_TYPE_bool :
                type = "bool";
                break;
            case PropertyDescription.CLIENT_PROP_TYPE_short :
                type = "short";
                break;
            case PropertyDescription.CLIENT_PROP_TYPE_string :
                type = "string";
                break;
            case PropertyDescription.CLIENT_PROP_TYPE_ModelObject :
                type = "ModelObject";
                break;
        }
        return type;
    }

Re: SOA: is it possible to get property names of given class or object type ?

Solution Partner Legend Solution Partner Legend
Solution Partner Legend
Thanks!! As suggested by you, following expression in C# gives me "SoaType" of Item class and SoaType has all the required information.

connection.ClientMetaModel.GetType("Item", connection)