Search in sources :

Example 16 with Type

use of model.Type in project uPMT by coco35700.

the class SchemaTransformations method SchemaToTreeView.

public static TreeItem<TypeController> SchemaToTreeView(Schema s) {
    TreeItem<TypeController> schema;
    TypeController ss = new TypeController(s, null);
    schema = new TreeItem<TypeController>(ss);
    schema.setExpanded(true);
    for (Type c : s.getTypes()) {
        addTypeTreeView(schema, c);
    }
    return schema;
}
Also used : TypeController(controller.controller.TypeController) Type(model.Type)

Example 17 with Type

use of model.Type in project pentaho-kettle by pentaho.

the class HL7KettleParser method parseStructure.

private static void parseStructure(List<HL7Value> values, Message message, Terser terser, Structure structure, String structureNumber) throws Exception {
    Map<String, List<String>> nameMap = NamesUtil.getInstance().getMap();
    if (structure instanceof Segment) {
        Segment segment = (Segment) structure;
        String[] names = segment.getNames();
        for (int n = 1; n <= segment.numFields(); n++) {
            Type[] types = segment.getField(n);
            for (int t = 0; t < types.length; t++) {
                int nrComponents = Terser.numComponents(types[t]);
                for (int c = 1; c <= nrComponents; c++) {
                    int nrSub = Terser.numSubComponents(types[t], c);
                    for (int sc = 1; sc <= nrSub; sc++) {
                        String string = Terser.get(segment, n, t, c, sc);
                        // Primitive primitive = Terser.getPrimitive(types[t], c, sc);
                        String description = "?";
                        List<String> list = nameMap.get(types[t].getName());
                        if (list != null && c - 1 < list.size()) {
                            description = list.get(c - 1);
                        }
                        Group group = structure.getParent();
                        Group rootGroup = structure.getMessage();
                        String coordinates = n + "." + (t + 1) + "." + c + "." + sc;
                        HL7Value value = new HL7Value(message.getVersion(), rootGroup.getName(), group.getName(), structure.getName(), structureNumber, names[n - 1], coordinates, types[t].getName(), description, string);
                        values.add(value);
                    }
                }
            }
        }
    } else if (structure instanceof Group) {
        Group group = (Group) structure;
        String[] names = group.getNames();
        for (int n = 1; n <= names.length; n++) {
            String name = names[n - 1];
            Structure subStructure = group.get(name);
            parseStructure(values, message, terser, subStructure, structureNumber + "." + n);
        }
    } else {
        throw new Exception("oops, not handled yet!");
    }
}
Also used : Group(ca.uhn.hl7v2.model.Group) Segment(ca.uhn.hl7v2.model.Segment) Type(ca.uhn.hl7v2.model.Type) List(java.util.List) ArrayList(java.util.ArrayList) Structure(ca.uhn.hl7v2.model.Structure)

Example 18 with Type

use of model.Type in project tdi-studio-se by Talend.

the class PrimitiveModel method generateDisplayName.

@Override
protected void generateDisplayName() {
    //$NON-NLS-1$
    String parentName = "";
    if (parent instanceof TypeModel) {
        TypeModel tm = (TypeModel) parent;
        Type type = tm.getType();
        String parentDisplayName = tm.getDisplayName();
        parentName = parentDisplayName;
        if (type != null) {
            String extensionName = type.getName();
            // int extensionIndex = parentDisplayName.indexOf(extensionName);
            // changed for bug TDI-19467
            int extensionIndex = parentDisplayName.lastIndexOf(extensionName);
            parentName = parentDisplayName.substring(0, extensionIndex - 1);
        }
    }
    String typeDispaly = primitive == null ? "" : TalendTextUtils.LBRACKET + this.primitive.getName() + TalendTextUtils.RBRACKET;
    //$NON-NLS-1$ //$NON-NLS-2$
    this.displayName = parentName + "-" + this.componentindex + "-" + this.subcomponentindex + typeDispaly;
}
Also used : Type(ca.uhn.hl7v2.model.Type)

Example 19 with Type

use of model.Type in project nifi by apache.

the class ExtractHL7Attributes method getAttributes.

public static Map<String, String> getAttributes(final Group group, final boolean useNames, final boolean parseFields) throws HL7Exception {
    final Map<String, String> attributes = new TreeMap<>();
    if (!isEmpty(group)) {
        for (final Map.Entry<String, Segment> segmentEntry : getAllSegments(group).entrySet()) {
            final String segmentKey = segmentEntry.getKey();
            final Segment segment = segmentEntry.getValue();
            final Map<String, Type> fields = getAllFields(segmentKey, segment, useNames);
            for (final Map.Entry<String, Type> fieldEntry : fields.entrySet()) {
                final String fieldKey = fieldEntry.getKey();
                final Type field = fieldEntry.getValue();
                // change the existing non-broken behavior of the processor
                if (parseFields && (field instanceof Composite) && !isTimestamp(field)) {
                    for (final Map.Entry<String, Type> componentEntry : getAllComponents(fieldKey, field, useNames).entrySet()) {
                        final String componentKey = componentEntry.getKey();
                        final Type component = componentEntry.getValue();
                        final String componentValue = HL7_ESCAPING.unescape(component.encode(), HL7_ENCODING);
                        if (!StringUtils.isEmpty(componentValue)) {
                            attributes.put(componentKey, componentValue);
                        }
                    }
                } else {
                    final String fieldValue = HL7_ESCAPING.unescape(field.encode(), HL7_ENCODING);
                    if (!StringUtils.isEmpty(fieldValue)) {
                        attributes.put(fieldKey, fieldValue);
                    }
                }
            }
        }
    }
    return attributes;
}
Also used : Type(ca.uhn.hl7v2.model.Type) Composite(ca.uhn.hl7v2.model.Composite) TreeMap(java.util.TreeMap) Map(java.util.Map) HashMap(java.util.HashMap) TreeMap(java.util.TreeMap) Segment(ca.uhn.hl7v2.model.Segment)

Example 20 with Type

use of model.Type in project nifi by apache.

the class ExtractHL7Attributes method getAllComponents.

private static Map<String, Type> getAllComponents(final String fieldKey, final Type field, final boolean useNames) throws HL7Exception {
    final Map<String, Type> components = new TreeMap<>();
    if (!isEmpty(field) && (field instanceof Composite)) {
        if (useNames) {
            final Pattern p = Pattern.compile("^(cm_msg|[a-z][a-z][a-z]?)([0-9]+)_(\\w+)$");
            try {
                final java.beans.PropertyDescriptor[] properties = PropertyUtils.getPropertyDescriptors(field);
                for (final java.beans.PropertyDescriptor property : properties) {
                    final String propertyName = property.getName();
                    final Matcher matcher = p.matcher(propertyName);
                    if (matcher.find()) {
                        final Type type = (Type) PropertyUtils.getProperty(field, propertyName);
                        if (!isEmpty(type)) {
                            final String componentName = matcher.group(3);
                            final String typeKey = new StringBuilder().append(fieldKey).append(".").append(componentName).toString();
                            components.put(typeKey, type);
                        }
                    }
                }
            } catch (Exception e) {
                throw new RuntimeException(e.getMessage(), e);
            }
        } else {
            final Type[] types = ((Composite) field).getComponents();
            for (int i = 0; i < types.length; i++) {
                final Type type = types[i];
                if (!isEmpty(type)) {
                    String fieldName = field.getName();
                    if (fieldName.equals("CM_MSG")) {
                        fieldName = "CM";
                    }
                    final String typeKey = new StringBuilder().append(fieldKey).append(".").append(fieldName).append(".").append(i + 1).toString();
                    components.put(typeKey, type);
                }
            }
        }
    }
    return components;
}
Also used : Pattern(java.util.regex.Pattern) Composite(ca.uhn.hl7v2.model.Composite) PropertyDescriptor(org.apache.nifi.components.PropertyDescriptor) Matcher(java.util.regex.Matcher) TreeMap(java.util.TreeMap) ProcessException(org.apache.nifi.processor.exception.ProcessException) HL7Exception(ca.uhn.hl7v2.HL7Exception) IOException(java.io.IOException) Type(ca.uhn.hl7v2.model.Type)

Aggregations

Type (model.Type)14 Type (ca.uhn.hl7v2.model.Type)10 AlertType (javafx.scene.control.Alert.AlertType)8 ButtonType (javafx.scene.control.ButtonType)5 HL7Exception (ca.uhn.hl7v2.HL7Exception)4 TypeController (controller.controller.TypeController)4 Property (model.Property)4 Composite (ca.uhn.hl7v2.model.Composite)3 ChangeListener (javafx.beans.value.ChangeListener)3 ObservableValue (javafx.beans.value.ObservableValue)3 Alert (javafx.scene.control.Alert)3 TreeItem (javafx.scene.control.TreeItem)3 KeyEvent (javafx.scene.input.KeyEvent)3 Category (model.Category)3 Group (ca.uhn.hl7v2.model.Group)2 Segment (ca.uhn.hl7v2.model.Segment)2 Structure (ca.uhn.hl7v2.model.Structure)2 Varies (ca.uhn.hl7v2.model.Varies)2 ArrayList (java.util.ArrayList)2 TreeMap (java.util.TreeMap)2