コード例 #1
0
    @Override
    protected String[] transformInternal(Attribute attr) throws Exception {
      String attrId = attr.getId();

      return (this.binaryAttrDetector.isBinary(attrId)
          ? ArrayUtils.toArray(getBinaryAttributeId(attrId), attrId)
          : ArrayUtils.toArray(attrId));
    }
コード例 #2
0
  @Override
  @SuppressWarnings({CompilerWarnings.UNCHECKED})
  protected void buildQuantityResourceParam(
      String type,
      Map<MultiKey<Serializable>, ResourceParam<?>> resourceParams,
      String name,
      ResourceParamMetadata resourceParamMetadata,
      XdmItem item,
      FhirResource entity)
      throws Exception {
    Object itemValue = this.decodeNode(((XdmNode) item));
    Quantity quantity = null;
    String units = null;
    URI codeSystemUri = null;
    BigDecimal value = null;

    if (itemValue instanceof Age) {
      quantity = ((Age) itemValue);
    } else if (itemValue instanceof Count) {
      quantity = ((Count) itemValue);
    } else if (itemValue instanceof Distance) {
      quantity = ((Distance) itemValue);
    } else if (itemValue instanceof Duration) {
      quantity = ((Duration) itemValue);
    } else if (itemValue instanceof Money) {
      quantity = ((Money) itemValue);
    } else if (itemValue instanceof Quantity) {
      quantity = ((Quantity) itemValue);
    }

    if (quantity != null) {
      codeSystemUri = (quantity.hasSystem() ? URI.create(quantity.getSystem().getValue()) : null);
      units = (quantity.hasCode() ? quantity.getCode().getValue() : null);
      value = quantity.getValue().getValue();
    } else {
      super.buildReferenceResourceParam(
          type, resourceParams, name, resourceParamMetadata, item, entity);
    }

    resourceParams.put(
        new MultiKey<>(ArrayUtils.toArray(name, codeSystemUri, null, units, null, value)),
        new QuantityResourceParamImpl(entity, name, codeSystemUri, null, units, null, value));
  }
コード例 #3
0
  @Test
  public void fromStrings() {
    GlobalConverter converter = new CharacterConverter(new MockConfiguration());
    Character cw =
        (Character)
            converter.convertFromStrings(
                Character.class, null, "testExpr", ArrayUtils.toArray((String) null));
    assertNull(cw);

    char c =
        (Character)
            converter.convertFromStrings(
                Character.TYPE, null, "testExpr", ArrayUtils.toArray((String) null));
    assertEquals(c, '\u0000');

    cw =
        (Character)
            converter.convertFromStrings(
                Character.class, null, "testExpr", ArrayUtils.toArray("c"));
    assertEquals((char) cw, 'c');

    c =
        (Character)
            converter.convertFromStrings(Character.TYPE, null, "testExpr", ArrayUtils.toArray("c"));
    assertEquals(c, 'c');

    cw =
        (Character)
            converter.convertFromStrings(
                Character.class, null, "testExpr", ArrayUtils.toArray(" "));
    assertNull(cw);

    c =
        (Character)
            converter.convertFromStrings(Character.TYPE, null, "testExpr", ArrayUtils.toArray(" "));
    assertEquals(c, 0);

    Character[] ca =
        (Character[])
            converter.convertFromStrings(
                Character[].class, null, "testExpr", ArrayUtils.toArray("c", "d"));
    assertEquals(ca[0], (Character) 'c');
    assertEquals(ca[1], (Character) 'd');

    char[] cpa =
        (char[])
            converter.convertFromStrings(
                char[].class, null, "testExpr", ArrayUtils.toArray("c", "d"));
    assertEquals(cpa[0], 'c');
    assertEquals(cpa[1], 'd');

    try {
      converter.convertFromStrings(Character.class, null, "testExpr", ArrayUtils.toArray("bad"));
      fail("Should have failed");
    } catch (ConversionException ce) {
      // Expected
    }

    try {
      converter.convertFromStrings(Character.TYPE, null, "testExpr", ArrayUtils.toArray("bad"));
      fail("Should have failed");
    } catch (ConversionException ce) {
      // Expected
    }
  }