Search in sources :

Example 1 with Property

use of mpern.sap.commerce.ccv2.model.Property in project org.hl7.fhir.core by hapifhir.

the class FHIRPathEngine method funcResolve.

private List<Base> funcResolve(ExecutionContext context, List<Base> focus, ExpressionNode exp) throws FHIRException {
    List<Base> result = new ArrayList<Base>();
    Base refContext = null;
    for (Base item : focus) {
        String s = convertToString(item);
        if (item.fhirType().equals("Reference")) {
            refContext = item;
            Property p = item.getChildByName("reference");
            if (p != null && p.hasValues()) {
                s = convertToString(p.getValues().get(0));
            } else {
                // a reference without any valid actual reference (just identifier or display, but we can't resolve it)
                s = null;
            }
        }
        if (item.fhirType().equals("canonical")) {
            s = item.primitiveValue();
            refContext = item;
        }
        if (s != null) {
            Base res = null;
            if (s.startsWith("#")) {
                Property p = context.rootResource.getChildByName("contained");
                if (p != null) {
                    for (Base c : p.getValues()) {
                        if (chompHash(s).equals(chompHash(c.getIdBase()))) {
                            res = c;
                            break;
                        }
                    }
                }
            } else if (hostServices != null) {
                res = hostServices.resolveReference(context.appInfo, s, refContext);
            }
            if (res != null) {
                result.add(res);
            }
        }
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) Property(org.hl7.fhir.r5.model.Property) Base(org.hl7.fhir.r5.model.Base)

Example 2 with Property

use of mpern.sap.commerce.ccv2.model.Property in project org.hl7.fhir.core by hapifhir.

the class FHIRPathEngine method getChildrenByName.

/**
 * Given an item, return all the children that conform to the pattern described in name
 *
 * Possible patterns:
 *  - a simple name (which may be the base of a name with [] e.g. value[x])
 *  - a name with a type replacement e.g. valueCodeableConcept
 *  - * which means all children
 *  - ** which means all descendants
 *
 * @param item
 * @param name
 * @param result
 * @throws FHIRException
 */
protected void getChildrenByName(Base item, String name, List<Base> result) throws FHIRException {
    String tn = null;
    if (isAllowPolymorphicNames()) {
        // we'll look to see whether we hav a polymorphic name
        for (Property p : item.children()) {
            if (p.getName().endsWith("[x]")) {
                String n = p.getName().substring(0, p.getName().length() - 3);
                if (name.startsWith(n)) {
                    tn = name.substring(n.length());
                    name = n;
                    break;
                }
            }
        }
    }
    Base[] list = item.listChildrenByName(name, false);
    if (list != null) {
        for (Base v : list) {
            if (v != null && (tn == null || v.fhirType().equalsIgnoreCase(tn))) {
                result.add(v);
            }
        }
    }
}
Also used : Property(org.hl7.fhir.r5.model.Property) Base(org.hl7.fhir.r5.model.Base)

Example 3 with Property

use of mpern.sap.commerce.ccv2.model.Property in project org.hl7.fhir.core by hapifhir.

the class NarrativeGenerator method splitExtensions.

private List<PropertyWrapper> splitExtensions(StructureDefinition profile, List<PropertyWrapper> children) throws UnsupportedEncodingException, IOException, FHIRException {
    List<PropertyWrapper> results = new ArrayList<PropertyWrapper>();
    Map<String, PropertyWrapper> map = new HashMap<String, PropertyWrapper>();
    for (PropertyWrapper p : children) if (p.getName().equals("extension") || p.getName().equals("modifierExtension")) {
        // we're going to split these up, and create a property for each url
        if (p.hasValues()) {
            for (BaseWrapper v : p.getValues()) {
                Extension ex = (Extension) v.getBase();
                String url = ex.getUrl();
                StructureDefinition ed = context.fetchResource(StructureDefinition.class, url);
                if (p.getName().equals("modifierExtension") && ed == null)
                    throw new DefinitionException("Unknown modifier extension " + url);
                PropertyWrapper pe = map.get(p.getName() + "[" + url + "]");
                if (pe == null) {
                    if (ed == null) {
                        if (url.startsWith("http://hl7.org/fhir"))
                            throw new DefinitionException("unknown extension " + url);
                        // System.out.println("unknown extension "+url);
                        pe = new PropertyWrapperDirect(new Property(p.getName() + "[" + url + "]", p.getTypeCode(), p.getDefinition(), p.getMinCardinality(), p.getMaxCardinality(), ex));
                    } else {
                        ElementDefinition def = ed.getSnapshot().getElement().get(0);
                        pe = new PropertyWrapperDirect(new Property(p.getName() + "[" + url + "]", "Extension", def.getDefinition(), def.getMin(), def.getMax().equals("*") ? Integer.MAX_VALUE : Integer.parseInt(def.getMax()), ex));
                        ((PropertyWrapperDirect) pe).wrapped.setStructure(ed);
                    }
                    results.add(pe);
                } else
                    pe.getValues().add(v);
            }
        }
    } else
        results.add(p);
    return results;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Extension(org.hl7.fhir.dstu3.model.Extension) StructureDefinition(org.hl7.fhir.dstu3.model.StructureDefinition) DefinitionException(org.hl7.fhir.exceptions.DefinitionException) ElementDefinition(org.hl7.fhir.dstu3.model.ElementDefinition) Property(org.hl7.fhir.dstu3.model.Property)

Example 4 with Property

use of mpern.sap.commerce.ccv2.model.Property in project target-java-sdk by adobe.

the class DefaultTargetClient method updatePropertyToken.

private void updatePropertyToken(TargetDeliveryRequest targetRequest) {
    if (StringUtils.isEmpty(this.defaultPropertyToken)) {
        return;
    }
    DeliveryRequest deliveryRequest = targetRequest.getDeliveryRequest();
    Property property = deliveryRequest.getProperty();
    if (property != null && property.getToken() != null) {
        return;
    }
    if (property == null) {
        property = new Property();
        deliveryRequest.setProperty(property);
    }
    property.setToken(this.defaultPropertyToken);
}
Also used : TargetDeliveryRequest(com.adobe.target.edge.client.model.TargetDeliveryRequest) DeliveryRequest(com.adobe.target.delivery.v1.model.DeliveryRequest) Property(com.adobe.target.delivery.v1.model.Property)

Example 5 with Property

use of mpern.sap.commerce.ccv2.model.Property in project target-java-sdk by adobe.

the class TelemetryServiceTest method testTelemetryForServerSide.

/**
 * Test case to call get offers for server side, in first request we capture the telemetry & in
 * next call we send it with any getOffers() call or sendNotifications() call
 *
 * @throws NoSuchFieldException
 */
@Test
void testTelemetryForServerSide() throws NoSuchFieldException {
    setup(true, DecisioningMethod.SERVER_SIDE, "testTelemetryForServerSide");
    Context context = getContext();
    PrefetchRequest prefetchRequest = getPrefetchViewsRequest();
    ExecuteRequest executeRequest = getMboxExecuteRequest();
    String nonDefaultToken = "non-default-token";
    TargetDeliveryRequest targetDeliveryRequest = TargetDeliveryRequest.builder().context(context).prefetch(prefetchRequest).execute(executeRequest).property(new Property().token(nonDefaultToken)).decisioningMethod(DecisioningMethod.SERVER_SIDE).build();
    TargetDeliveryResponse targetDeliveryResponse1 = targetJavaClient.getOffers(targetDeliveryRequest);
    assertNull(targetDeliveryResponse1.getRequest().getTelemetry());
    // In next call we see telemetry data added to the deliveryRequest
    TargetDeliveryResponse targetDeliveryResponse2 = targetJavaClient.getOffers(targetDeliveryRequest);
    verify(telemetryServiceSpy, atLeast(2)).getTelemetry();
    verify(telemetryServiceSpy, times(2)).addTelemetry(any(TargetDeliveryRequest.class), any(TimingTool.class), any(TargetDeliveryResponse.class), any(Double.class), any(Long.class));
    assertEquals(1, telemetryServiceSpy.getTelemetry().getEntries().size());
    assertNotNull(targetDeliveryResponse2);
    assertNotNull(targetDeliveryResponse2.getRequest());
    assertNotNull(targetDeliveryResponse2.getRequest().getTelemetry());
    assertEquals(1, targetDeliveryResponse2.getRequest().getTelemetry().getEntries().size());
}
Also used : Context(com.adobe.target.delivery.v1.model.Context) TargetTestDeliveryRequestUtils.getContext(com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getContext) PrefetchRequest(com.adobe.target.delivery.v1.model.PrefetchRequest) TargetTestDeliveryRequestUtils.getMboxExecuteRequest(com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getMboxExecuteRequest) ExecuteRequest(com.adobe.target.delivery.v1.model.ExecuteRequest) TargetDeliveryResponse(com.adobe.target.edge.client.model.TargetDeliveryResponse) TimingTool(com.adobe.target.edge.client.utils.TimingTool) TargetDeliveryRequest(com.adobe.target.edge.client.model.TargetDeliveryRequest) Property(com.adobe.target.delivery.v1.model.Property) Test(org.junit.jupiter.api.Test)

Aggregations

Property (com.adobe.target.delivery.v1.model.Property)9 TargetDeliveryRequest (com.adobe.target.edge.client.model.TargetDeliveryRequest)9 Test (org.junit.jupiter.api.Test)9 Context (com.adobe.target.delivery.v1.model.Context)8 ExecuteRequest (com.adobe.target.delivery.v1.model.ExecuteRequest)8 TargetDeliveryResponse (com.adobe.target.edge.client.model.TargetDeliveryResponse)8 TargetTestDeliveryRequestUtils.getContext (com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getContext)8 TargetTestDeliveryRequestUtils.getMboxExecuteRequest (com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getMboxExecuteRequest)8 TimingTool (com.adobe.target.edge.client.utils.TimingTool)8 PrefetchRequest (com.adobe.target.delivery.v1.model.PrefetchRequest)7 Property (io.adminshell.aas.v3.model.Property)7 DeliveryResponse (com.adobe.target.delivery.v1.model.DeliveryResponse)5 TargetTestDeliveryRequestUtils.getNoContentDeliveryResponse (com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getNoContentDeliveryResponse)5 TargetTestDeliveryRequestUtils.getTestDeliveryResponse (com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getTestDeliveryResponse)5 ArrayList (java.util.ArrayList)5 TelemetryEntry (com.adobe.target.delivery.v1.model.TelemetryEntry)4 SubmodelElement (io.adminshell.aas.v3.model.SubmodelElement)4 HashMap (java.util.HashMap)4 Property (model.Property)4 InputStream (java.io.InputStream)3