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;
}
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);
}
}
}
}
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;
}
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);
}
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());
}
Aggregations