Search in sources :

Example 1 with JSONDeserializer

use of flexjson.JSONDeserializer in project pentaho-metaverse by pentaho.

the class MetaverseUtil method convertOperationsStringToMap.

public static Operations convertOperationsStringToMap(String operations) {
    Operations resultOps = null;
    if (!Const.isEmpty(operations)) {
        try {
            Map<String, List<IOperation>> rawOpsMap = new JSONDeserializer<Map<String, List<IOperation>>>().use("values.values", Operation.class).deserialize(operations);
            resultOps = new Operations();
            for (String key : rawOpsMap.keySet()) {
                resultOps.put(ChangeType.forValue(key), rawOpsMap.get(key));
            }
        } catch (Exception e) {
            resultOps = null;
        }
    // return new JSONDeserializer<Operations>().use(null, Operations.class).deserialize( operations );
    }
    return resultOps;
}
Also used : List(java.util.List) JSONDeserializer(flexjson.JSONDeserializer) IOperation(org.pentaho.metaverse.api.model.IOperation) Operation(org.pentaho.metaverse.api.model.Operation) Operations(org.pentaho.metaverse.api.model.Operations) MetaverseException(org.pentaho.metaverse.api.MetaverseException) MetaverseAnalyzerException(org.pentaho.metaverse.api.MetaverseAnalyzerException)

Example 2 with JSONDeserializer

use of flexjson.JSONDeserializer in project data-access by pentaho.

the class DatabaseConnectionListReaderWriter method readFrom.

@Override
public IDatabaseConnectionList readFrom(Class<IDatabaseConnectionList> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException, WebApplicationException {
    JSONDeserializer<DefaultDatabaseConnectionList> jsonD = new JSONDeserializer<DefaultDatabaseConnectionList>();
    jsonD.use("databaseType", DatabaseType.class);
    return jsonD.deserialize(new InputStreamReader(entityStream), DefaultDatabaseConnectionList.class);
}
Also used : InputStreamReader(java.io.InputStreamReader) DefaultDatabaseConnectionList(org.pentaho.ui.database.event.DefaultDatabaseConnectionList) JSONDeserializer(flexjson.JSONDeserializer)

Example 3 with JSONDeserializer

use of flexjson.JSONDeserializer in project data-access by pentaho.

the class DatabaseConnectionReaderWriter method readFrom.

@Override
public DatabaseConnection readFrom(Class<DatabaseConnection> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException, WebApplicationException {
    JSONDeserializer<DatabaseConnection> jsonD = new JSONDeserializer<DatabaseConnection>();
    jsonD.use("databaseType", DatabaseType.class);
    return jsonD.deserialize(new InputStreamReader(entityStream), DatabaseConnection.class);
}
Also used : InputStreamReader(java.io.InputStreamReader) DatabaseConnection(org.pentaho.database.model.DatabaseConnection) IDatabaseConnection(org.pentaho.database.model.IDatabaseConnection) JSONDeserializer(flexjson.JSONDeserializer)

Aggregations

JSONDeserializer (flexjson.JSONDeserializer)3 InputStreamReader (java.io.InputStreamReader)2 List (java.util.List)1 DatabaseConnection (org.pentaho.database.model.DatabaseConnection)1 IDatabaseConnection (org.pentaho.database.model.IDatabaseConnection)1 MetaverseAnalyzerException (org.pentaho.metaverse.api.MetaverseAnalyzerException)1 MetaverseException (org.pentaho.metaverse.api.MetaverseException)1 IOperation (org.pentaho.metaverse.api.model.IOperation)1 Operation (org.pentaho.metaverse.api.model.Operation)1 Operations (org.pentaho.metaverse.api.model.Operations)1 DefaultDatabaseConnectionList (org.pentaho.ui.database.event.DefaultDatabaseConnectionList)1