APISonar


grakn.core.kb.concept.api.AttributeType.DataType.DATE

> grakn > core > kb > concept > api > AttributeType > DataType > DATE
grakn APIs core APIs kb APIs concept APIs api APIs AttributeType APIs DataType APIs DATE APIs

Example 1
public void whenSavingDateIntoResource_DateIsReturnedInSameFormat() {
        LocalDateTime date = LocalDateTime.now();
        AttributeType<LocalDateTime> attributeType = tx.putAttributeType("My Birthday", AttributeType.DataType.DATE);
        Attribute<LocalDateTime> myBirthday = attributeType.create(date);

        assertEquals(date, myBirthday.value());
        assertEquals(myBirthday, attributeType.attribute(date));
        assertThat(tx.getAttributesByValue(date), containsInAnyOrder(myBirthday));
    }
Example 2
public void whenCreatingResourceWithAnInvalidDataTypeOnADate_Throw() {
        String invalidThing = "Invalid Thing";
        AttributeType longAttributeType = tx.putAttributeType("date", AttributeType.DataType.DATE);
        expectedException.expect(GraknConceptException.class);
        expectedException.expectMessage(GraknConceptException.invalidAttributeValue(invalidThing, AttributeType.DataType.DATE).getMessage());
        longAttributeType.create(invalidThing);
    }
Example 3
private DataTypeAtom dataType(Variable var, DataTypeProperty property, ReasonerQuery parent) {
        ImmutableMap.Builder<Graql.Token.DataType, AttributeType.DataType<?>> dataTypesBuilder = new ImmutableMap.Builder<>();
        dataTypesBuilder.put(Graql.Token.DataType.BOOLEAN, AttributeType.DataType.BOOLEAN);
        dataTypesBuilder.put(Graql.Token.DataType.DATE, AttributeType.DataType.DATE);
        dataTypesBuilder.put(Graql.Token.DataType.DOUBLE, AttributeType.DataType.DOUBLE);
        dataTypesBuilder.put(Graql.Token.DataType.LONG, AttributeType.DataType.LONG);
        dataTypesBuilder.put(Graql.Token.DataType.STRING, AttributeType.DataType.STRING);
        ImmutableMap<Graql.Token.DataType, AttributeType.DataType<?>> dataTypes = dataTypesBuilder.build();
        return DataTypeAtom.create(var, property, parent, dataTypes.get(property.dataType()));
    }