Search in sources :

Example 1 with ListParamValue

use of org.pentaho.platform.scheduler2.ws.ListParamValue in project pentaho-platform by pentaho.

the class JaxWsSchedulerServiceIT method generateFullJobParams.

private static Map<String, ParamValue> generateFullJobParams() {
    HashMap<String, ParamValue> privateParams = new HashMap<String, ParamValue>();
    ListParamValue listValue = new ListParamValue();
    listValue.add("testListVal0");
    listValue.add("testListVal1");
    MapParamValue mapValue = new MapParamValue();
    mapValue.put("testMapKey0", "testMapVal0");
    mapValue.put("testMapKey1", "testMapVal1");
    privateParams.put("stringParam", new StringParamValue("testStringValue"));
    privateParams.put("listParam", listValue);
    privateParams.put("mapParam", mapValue);
    return privateParams;
}
Also used : ListParamValue(org.pentaho.platform.scheduler2.ws.ListParamValue) MapParamValue(org.pentaho.platform.scheduler2.ws.MapParamValue) HashMap(java.util.HashMap) ListParamValue(org.pentaho.platform.scheduler2.ws.ListParamValue) ParamValue(org.pentaho.platform.scheduler2.ws.ParamValue) StringParamValue(org.pentaho.platform.scheduler2.ws.StringParamValue) MapParamValue(org.pentaho.platform.scheduler2.ws.MapParamValue) StringParamValue(org.pentaho.platform.scheduler2.ws.StringParamValue)

Example 2 with ListParamValue

use of org.pentaho.platform.scheduler2.ws.ListParamValue in project pentaho-platform by pentaho.

the class ActionAdapterQuartzJob method getSerializableMap.

private static Map<String, Serializable> getSerializableMap(final Map<String, Serializable> originalMap) {
    final Map<String, Serializable> serializableMap = new HashMap<>();
    final Iterator<Map.Entry<String, Serializable>> iter = originalMap.entrySet().iterator();
    while (iter.hasNext()) {
        final Map.Entry<String, Serializable> entry = iter.next();
        final String key = entry.getKey();
        final Serializable value = entry.getValue();
        if (value instanceof MapParamValue) {
            serializableMap.put(key, new HashMap<String, Serializable>((MapParamValue) value));
        } else if (value instanceof ListParamValue) {
            serializableMap.put(key, new ArrayList<Serializable>((ListParamValue) value));
        } else if (value instanceof StringParamValue) {
            serializableMap.put(key, ((StringParamValue) value).getStringValue());
        } else {
            serializableMap.put(key, value);
        }
    }
    return serializableMap;
}
Also used : Serializable(java.io.Serializable) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) StringParamValue(org.pentaho.platform.scheduler2.ws.StringParamValue) ListParamValue(org.pentaho.platform.scheduler2.ws.ListParamValue) MapParamValue(org.pentaho.platform.scheduler2.ws.MapParamValue) HashMap(java.util.HashMap) Map(java.util.Map) JobDataMap(org.quartz.JobDataMap)

Example 3 with ListParamValue

use of org.pentaho.platform.scheduler2.ws.ListParamValue in project pentaho-platform by pentaho.

the class ComplianceJaxBTest method testJaxbSafeMap.

@Test
public void testJaxbSafeMap() throws JAXBException {
    HashMap<String, ParamValue> params = new HashMap<String, ParamValue>();
    ListParamValue listValue = new ListParamValue();
    listValue.add("testListVal0");
    listValue.add("testListVal1");
    MapParamValue mapValue = new MapParamValue();
    mapValue.put("testMapValueKey", "testMapVal");
    params.put("testStringkey", new StringParamValue("testStringVal"));
    params.put("testListKey", listValue);
    params.put("testMapKey", mapValue);
    // TreeMap implements java.util.SortedMap; applies a natural ordering of its keys;
    Map<String, ParamValue> sortedParams = new TreeMap(params);
    List paramsList = java.util.Arrays.asList(sortedParams.keySet().toArray());
    JaxBSafeMap map = new JaxBSafeMap(sortedParams);
    JaxBSafeMap unmarshalled = JaxBUtil.outin(map, JaxBSafeMap.class, JaxBSafeEntry.class, StringParamValue.class);
    Assert.assertEquals("testStringVal", unmarshalled.entry.get(paramsList.indexOf("testStringkey")).getStringValue().toString());
    Assert.assertEquals("testListVal0", unmarshalled.entry.get(paramsList.indexOf("testListKey")).getListValue().get(0));
    Assert.assertEquals("testMapVal", unmarshalled.entry.get(paramsList.indexOf("testMapKey")).getMapValue().get("testMapValueKey"));
}
Also used : ListParamValue(org.pentaho.platform.scheduler2.ws.ListParamValue) MapParamValue(org.pentaho.platform.scheduler2.ws.MapParamValue) HashMap(java.util.HashMap) JaxBSafeMap(org.pentaho.platform.scheduler2.ws.JaxBSafeMap) ListParamValue(org.pentaho.platform.scheduler2.ws.ListParamValue) ParamValue(org.pentaho.platform.scheduler2.ws.ParamValue) StringParamValue(org.pentaho.platform.scheduler2.ws.StringParamValue) MapParamValue(org.pentaho.platform.scheduler2.ws.MapParamValue) StringParamValue(org.pentaho.platform.scheduler2.ws.StringParamValue) List(java.util.List) TreeMap(java.util.TreeMap) Test(org.junit.Test)

Example 4 with ListParamValue

use of org.pentaho.platform.scheduler2.ws.ListParamValue in project pentaho-platform by pentaho.

the class JobAdapter method toParamValueMap.

@SuppressWarnings("unchecked")
private Map<String, ParamValue> toParamValueMap(Map<String, Serializable> unsafeMap) {
    Map<String, ParamValue> paramValueMap = new HashMap<String, ParamValue>();
    for (Map.Entry<String, Serializable> entry : unsafeMap.entrySet()) {
        if (entry.getValue() instanceof Map) {
            // convert the inner map
            MapParamValue map = new MapParamValue();
            Map innerMap = (Map) entry.getValue();
            Set<Map.Entry> entrySet = innerMap.entrySet();
            for (Map.Entry innerEntry : entrySet) {
                map.put(innerEntry.getKey().toString(), (innerEntry.getValue() == null) ? null : innerEntry.getValue().toString());
            }
            // add the converted map the the top-level map
            paramValueMap.put(entry.getKey(), map);
        } else if (entry.getValue() instanceof List) {
            ListParamValue list = new ListParamValue();
            List innerList = (List) entry.getValue();
            list.addAll(innerList);
            paramValueMap.put(entry.getKey(), list);
        } else {
            paramValueMap.put(entry.getKey(), new StringParamValue((entry.getValue() == null) ? null : entry.getValue().toString()));
        }
    }
    return paramValueMap;
}
Also used : Serializable(java.io.Serializable) HashMap(java.util.HashMap) JaxBSafeEntry(org.pentaho.platform.scheduler2.ws.JaxBSafeMap.JaxBSafeEntry) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

HashMap (java.util.HashMap)4 ListParamValue (org.pentaho.platform.scheduler2.ws.ListParamValue)3 MapParamValue (org.pentaho.platform.scheduler2.ws.MapParamValue)3 StringParamValue (org.pentaho.platform.scheduler2.ws.StringParamValue)3 Serializable (java.io.Serializable)2 List (java.util.List)2 Map (java.util.Map)2 ParamValue (org.pentaho.platform.scheduler2.ws.ParamValue)2 ArrayList (java.util.ArrayList)1 TreeMap (java.util.TreeMap)1 Test (org.junit.Test)1 JaxBSafeMap (org.pentaho.platform.scheduler2.ws.JaxBSafeMap)1 JaxBSafeEntry (org.pentaho.platform.scheduler2.ws.JaxBSafeMap.JaxBSafeEntry)1 JobDataMap (org.quartz.JobDataMap)1