@NotNull @Override public Value getLastUpdate() { return valueTableDirectory.exists() ? DateTimeType.get().valueOf(new Date(valueTableDirectory.lastModified())) : DateTimeType.get().nullValue(); }
@Test public void test_engine_method() { JavascriptValueSource source = new JavascriptValueSource(DateTimeType.get(), "now()"); source.initialise(); Value value = source.getValue(mockValueSet); assertThat(value).isNotNull(); assertThat(value.isNull()).isFalse(); assertThat(value.getValueType()).isEqualTo(DateTimeType.get()); Date dateValue = (Date) value.getValue(); // Make sure both dates are within 1 second of one-another assertThat(System.currentTimeMillis() - dateValue.getTime()).isLessThan(1000); }
public XContentBuilder updateTimestamps(String name) { try { XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject(name); mapping .startObject("_meta") .field("_updated", DateTimeType.get().valueOf(new Date()).toString()) .endObject(); mapping .endObject() // type .endObject(); // mapping return mapping; } catch (IOException e) { throw new RuntimeException(e); } }
protected void updateTimestamps() { try { EsMapping mapping = readMapping(); //noinspection ConstantConditions mapping.meta().setString("_updated", DateTimeType.get().valueOf(new Date()).toString()); opalSearchService .getClient() .admin() .indices() .preparePutMapping(getName()) .setType(getIndexName()) .setSource(mapping.toXContent()) .execute() .actionGet(); } catch (IOException e) { throw new RuntimeException(e); } }
public XContentBuilder createMapping( Version opalVersion, String indexName, ValueTable valueTable) { try { XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject(indexName); mapping.startObject("_all").field("enabled", false).endObject(); mapping.startObject("_parent").field("type", valueTable.getEntityType()).endObject(); mapping.startObject("properties"); mapping .startObject("_id.analyzed") // .field("type", "string") // .field("index", "analyzed") // .field("index_analyzer", "opal_index_analyzer") // .field("search_analyzer", "opal_search_analyzer"); mapping.endObject(); for (Variable variable : valueTable.getVariables()) { variableMappings.map(indexName, variable, mapping); } mapping.endObject(); // properties mapping .startObject("_meta") // .field("_created", DateTimeType.get().valueOf(new Date()).toString()) // .field("_opalversion", opalVersion.toString()) // .field( "_reference", valueTable.getDatasource().getName() + "." + valueTable.getName()) // .endObject(); mapping .endObject() // type .endObject(); // mapping return mapping; } catch (IOException e) { throw new RuntimeException(e); } }
@NotNull @Override public Value getCreated() { // Not currently possible to read a file creation timestamp. Coming in JDK 7 NIO. return DateTimeType.get().nullValue(); }