コード例 #1
0
 private String getSortKey(Object value) {
   if (value instanceof PrestoTopic) {
     PrestoTopic topic = (PrestoTopic) value;
     return topic.getName(field);
   } else {
     return value == null ? null : value.toString();
   }
 }
コード例 #2
0
  @Override
  public void create(PrestoTopic topic) {
    String topicId = topic.getId();
    String typeId = topic.getTypeId();
    if (topicId == null) {
      ObjectNode data = ((JacksonTopic) topic).getData();
      topicId = identityStrategy.generateId(typeId, data);
      data.put("_id", topicId);
    }

    if (topics.containsKey(topicId)) {
      throw new RuntimeException("Topic with id '" + topicId + "' already created.");
    } else {
      if (topicId == null) {
        throw new NullPointerException();
      }
      topics.put(topicId, topic);
    }
  }
コード例 #3
0
 @Override
 public void update(PrestoTopic topic) {
   String topicId = topic.getId();
   if (topicId == null) {
     throw new NullPointerException();
   }
   if (topics.containsKey(topicId)) {
     topics.put(topicId, topic);
   } else {
     throw new RuntimeException("Topic with id '" + topicId + "' not an existing topic.");
   }
 }
コード例 #4
0
    private ValueFieldConfig getValueFieldConfig(PrestoTopic valueTopic, String valueFieldId) {
      String valueTypeId = valueTopic.getTypeId();

      ValueFieldConfig valueFieldConfig = valueFieldConfigCache.get(valueTypeId);
      if (valueFieldConfig == null) {

        PrestoDataProvider dataProvider = presto.getDataProvider();
        PrestoSchemaProvider schemaProvider = presto.getSchemaProvider();
        PrestoType valueType = schemaProvider.getTypeById(valueTypeId);
        PrestoField valueField = valueType.getFieldById(valueFieldId);

        Comparator<Object> valueComparator = null;
        ObjectNode extra = ExtraUtils.getFieldExtraNode(valueField);
        if (extra != null) {
          JsonNode handlerNode = extra.path("valueComparator");
          if (handlerNode.isObject()) {
            FieldValueComparator handler =
                AbstractHandler.getHandler(
                    dataProvider,
                    schemaProvider,
                    FieldValueComparator.class,
                    (ObjectNode) handlerNode);
            if (handler != null) {
              handler.setPresto(presto);
            }
            valueComparator = handler;
          }
        }
        if (valueComparator == null) {
          valueComparator = new FieldComparator(valueField, false);
        }
        valueFieldConfig = new ValueFieldConfig(presto, rules, field, valueField, valueComparator);
        valueFieldConfigCache.put(valueTypeId, valueFieldConfig);
      }
      return valueFieldConfig;
    }
コード例 #5
0
 @Override
 public boolean delete(PrestoTopic topic) {
   String topicId = topic.getId();
   return topics.remove(topicId) != null;
 }