Ejemplo n.º 1
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);
    }
  }
Ejemplo n.º 2
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;
    }