Search in sources :

Example 1 with Field

use of com.hortonworks.registries.common.Schema.Field in project streamline by hortonworks.

the class MLModel method getPrimaryKey.

@JsonIgnore
@Override
public PrimaryKey getPrimaryKey() {
    Map<Field, Object> fieldObjectMap = new HashMap<>();
    fieldObjectMap.put(new Schema.Field(ID, Type.LONG), this.id);
    return new PrimaryKey(fieldObjectMap);
}
Also used : Field(com.hortonworks.registries.common.Schema.Field) HashMap(java.util.HashMap) Schema(com.hortonworks.registries.common.Schema) PrimaryKey(com.hortonworks.registries.storage.PrimaryKey) Field(com.hortonworks.registries.common.Schema.Field) JsonIgnore(com.fasterxml.jackson.annotation.JsonIgnore)

Example 2 with Field

use of com.hortonworks.registries.common.Schema.Field in project streamline by hortonworks.

the class TopologyStream method setFieldsData.

// for internal storage, not part of JSON
@JsonIgnore
public void setFieldsData(String fieldsData) throws Exception {
    if (fieldsData == null || fieldsData.isEmpty()) {
        return;
    }
    ObjectMapper mapper = new ObjectMapper();
    fields = mapper.readValue(fieldsData, new TypeReference<List<Field>>() {
    });
}
Also used : Field(com.hortonworks.registries.common.Schema.Field) TypeReference(com.fasterxml.jackson.core.type.TypeReference) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) JsonIgnore(com.fasterxml.jackson.annotation.JsonIgnore)

Example 3 with Field

use of com.hortonworks.registries.common.Schema.Field in project streamline by hortonworks.

the class TopologyStream method getPrimaryKey.

@JsonIgnore
@Override
public PrimaryKey getPrimaryKey() {
    Map<Field, Object> fieldToObjectMap = new HashMap<>();
    fieldToObjectMap.put(new Schema.Field(ID, Schema.Type.LONG), this.id);
    fieldToObjectMap.put(new Schema.Field(VERSIONID, Schema.Type.LONG), this.versionId);
    return new PrimaryKey(fieldToObjectMap);
}
Also used : Field(com.hortonworks.registries.common.Schema.Field) HashMap(java.util.HashMap) Schema(com.hortonworks.registries.common.Schema) PrimaryKey(com.hortonworks.registries.storage.PrimaryKey) Field(com.hortonworks.registries.common.Schema.Field) JsonIgnore(com.fasterxml.jackson.annotation.JsonIgnore)

Example 4 with Field

use of com.hortonworks.registries.common.Schema.Field in project streamline by hortonworks.

the class TopologyStream method fromMap.

@Override
public Storable fromMap(Map<String, Object> map) {
    setId((Long) map.get(ID));
    setVersionId((Long) map.get(VERSIONID));
    setStreamId((String) map.get(STREAMID));
    setDescription((String) map.get(DESCRIPTION));
    setTopologyId((Long) map.get(TOPOLOGYID));
    ObjectMapper mapper = new ObjectMapper();
    String fieldsDataStr = (String) map.get(FIELDSDATA);
    if (!StringUtils.isEmpty(fieldsDataStr)) {
        List<Field> fields;
        try {
            fields = mapper.readValue(fieldsDataStr, new TypeReference<List<Field>>() {
            });
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        setFields(fields);
    }
    return this;
}
Also used : Field(com.hortonworks.registries.common.Schema.Field) TypeReference(com.fasterxml.jackson.core.type.TypeReference) IOException(java.io.IOException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 5 with Field

use of com.hortonworks.registries.common.Schema.Field in project registry by hortonworks.

the class MLModel method getPrimaryKey.

@JsonIgnore
@Override
public PrimaryKey getPrimaryKey() {
    Map<Field, Object> fieldObjectMap = new HashMap<>();
    fieldObjectMap.put(new Schema.Field(ID, Type.LONG), this.id);
    return new PrimaryKey(fieldObjectMap);
}
Also used : Field(com.hortonworks.registries.common.Schema.Field) HashMap(java.util.HashMap) Schema(com.hortonworks.registries.common.Schema) PrimaryKey(com.hortonworks.registries.storage.PrimaryKey) Field(com.hortonworks.registries.common.Schema.Field) JsonIgnore(com.fasterxml.jackson.annotation.JsonIgnore)

Aggregations

Field (com.hortonworks.registries.common.Schema.Field)5 JsonIgnore (com.fasterxml.jackson.annotation.JsonIgnore)4 Schema (com.hortonworks.registries.common.Schema)3 PrimaryKey (com.hortonworks.registries.storage.PrimaryKey)3 HashMap (java.util.HashMap)3 TypeReference (com.fasterxml.jackson.core.type.TypeReference)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 IOException (java.io.IOException)1