Search in sources :

Example 21 with DataMap

use of com.linkedin.data.DataMap in project rest.li by linkedin.

the class BatchCreateIdEntityResponse method generateDataMap.

private static DataMap generateDataMap(List<? extends RecordTemplate> elements) {
    DataMap dataMap = new DataMap();
    DataList listElements = new DataList();
    for (RecordTemplate recordTemplate : elements) {
        CreateIdEntityStatus<?, ?> status = (CreateIdEntityStatus) recordTemplate;
        CheckedUtil.addWithoutChecking(listElements, status.data());
    }
    dataMap.put(CollectionResponse.ELEMENTS, listElements);
    return dataMap;
}
Also used : DataList(com.linkedin.data.DataList) RecordTemplate(com.linkedin.data.template.RecordTemplate) DataMap(com.linkedin.data.DataMap)

Example 22 with DataMap

use of com.linkedin.data.DataMap in project rest.li by linkedin.

the class BatchCreateIdResponse method generateDataMap.

private static DataMap generateDataMap(List<? extends RecordTemplate> elements) {
    DataMap dataMap = new DataMap();
    DataList listElements = new DataList();
    for (RecordTemplate recordTemplate : elements) {
        CheckedUtil.addWithoutChecking(listElements, recordTemplate.data());
    }
    dataMap.put(CollectionResponse.ELEMENTS, listElements);
    return dataMap;
}
Also used : DataList(com.linkedin.data.DataList) RecordTemplate(com.linkedin.data.template.RecordTemplate) DataMap(com.linkedin.data.DataMap)

Example 23 with DataMap

use of com.linkedin.data.DataMap in project rest.li by linkedin.

the class BatchCreateResponse method generateDataMap.

private static DataMap generateDataMap(List<? extends RecordTemplate> elements) {
    DataMap dataMap = new DataMap();
    DataList listElements = new DataList();
    for (RecordTemplate recordTemplate : elements) {
        listElements.add(recordTemplate.data());
    }
    dataMap.put(CollectionResponse.ELEMENTS, listElements);
    return dataMap;
}
Also used : DataList(com.linkedin.data.DataList) RecordTemplate(com.linkedin.data.template.RecordTemplate) DataMap(com.linkedin.data.DataMap)

Example 24 with DataMap

use of com.linkedin.data.DataMap in project rest.li by linkedin.

the class BatchCreateResponse method createCollectionFromDecoder.

private List<CreateStatus> createCollectionFromDecoder(CreateIdStatusDecoder<K> entityDecoder) throws NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException {
    DataList elements = this.data().getDataList(CollectionResponse.ELEMENTS);
    List<CreateStatus> collection = new ArrayList<CreateStatus>(elements.size());
    for (Object obj : elements) {
        DataMap dataMap = (DataMap) obj;
        collection.add(decodeValue(dataMap, entityDecoder));
    }
    return collection;
}
Also used : DataList(com.linkedin.data.DataList) ArrayList(java.util.ArrayList) DataMap(com.linkedin.data.DataMap)

Example 25 with DataMap

use of com.linkedin.data.DataMap in project rest.li by linkedin.

the class ComplexResourceKey method buildFromDataMap.

/**
   * Build complex key instance from an untyped datamap representing a complex key as
   * defined in {@link QueryParamsDataMap}
   *
   * @param keyDataMap untyped DataMap - all primitive values are represented as strings.
   * @param complexKeyType type of {@link ComplexResourceKey}
   * @return {@link ComplexResourceKey} initialized with id and param values specified in
   *         the input DataMap
   */
public static ComplexResourceKey<RecordTemplate, RecordTemplate> buildFromDataMap(DataMap keyDataMap, ComplexKeySpec<?, ?> complexKeyType) {
    // Copy in case the original is immutable
    keyDataMap = new DataMap(keyDataMap);
    // Separate key from its parameters (those are under "params" key in the total map)
    DataMap paramsDataMap = (DataMap) keyDataMap.remove(COMPLEX_KEY_PARAMS);
    if (paramsDataMap == null) {
        paramsDataMap = new DataMap();
    }
    RecordTemplate key = validateDataMap(keyDataMap, complexKeyType.getKeyType());
    RecordTemplate params = validateDataMap(paramsDataMap, complexKeyType.getParamsType());
    return new ComplexResourceKey<RecordTemplate, RecordTemplate>(key, params);
}
Also used : RecordTemplate(com.linkedin.data.template.RecordTemplate) DataMap(com.linkedin.data.DataMap) QueryParamsDataMap(com.linkedin.restli.internal.common.QueryParamsDataMap)

Aggregations

DataMap (com.linkedin.data.DataMap)471 Test (org.testng.annotations.Test)238 DataList (com.linkedin.data.DataList)130 ByteString (com.linkedin.data.ByteString)110 HashMap (java.util.HashMap)56 TestUtil.dataMapFromString (com.linkedin.data.TestUtil.dataMapFromString)49 RecordDataSchema (com.linkedin.data.schema.RecordDataSchema)47 TestUtil.dataSchemaFromString (com.linkedin.data.TestUtil.dataSchemaFromString)46 DataSchema (com.linkedin.data.schema.DataSchema)45 Map (java.util.Map)45 ArrayList (java.util.ArrayList)31 MaskTree (com.linkedin.data.transform.filter.request.MaskTree)23 PathSpec (com.linkedin.data.schema.PathSpec)21 RecordTemplate (com.linkedin.data.template.RecordTemplate)21 DataProvider (org.testng.annotations.DataProvider)20 HashSet (java.util.HashSet)19 ArrayDataSchema (com.linkedin.data.schema.ArrayDataSchema)18 PatchTree (com.linkedin.data.transform.patch.request.PatchTree)18 CompoundKey (com.linkedin.restli.common.CompoundKey)18 IOException (java.io.IOException)18