Search in sources :

Example 71 with Value

use of com.google.firestore.v1beta1.Value in project googleads-java-lib by googleads.

the class PqlTest method testCreateValue_numberSet.

@Test
public void testCreateValue_numberSet() {
    Set<Long> numberSet = new LinkedHashSet<Long>();
    numberSet.add(1L);
    Value value1 = ((SetValue) Pql.createValue(numberSet)).getValues(0);
    assertEquals("1", ((NumberValue) value1).getValue());
}
Also used : LinkedHashSet(java.util.LinkedHashSet) DateValue(com.google.api.ads.admanager.axis.v202108.DateValue) TargetingValue(com.google.api.ads.admanager.axis.v202108.TargetingValue) DateTimeValue(com.google.api.ads.admanager.axis.v202108.DateTimeValue) BooleanValue(com.google.api.ads.admanager.axis.v202108.BooleanValue) TextValue(com.google.api.ads.admanager.axis.v202108.TextValue) Value(com.google.api.ads.admanager.axis.v202108.Value) SetValue(com.google.api.ads.admanager.axis.v202108.SetValue) NumberValue(com.google.api.ads.admanager.axis.v202108.NumberValue) SetValue(com.google.api.ads.admanager.axis.v202108.SetValue) Test(org.junit.Test)

Example 72 with Value

use of com.google.firestore.v1beta1.Value in project googleads-java-lib by googleads.

the class PqlTest method testCreateValue_dateTimeSet.

@Test
public void testCreateValue_dateTimeSet() {
    Set<DateTime> dateTimeSet = new LinkedHashSet<DateTime>();
    dateTimeSet.add(dateTime1);
    Value value1 = ((SetValue) Pql.createValue(dateTimeSet)).getValues(0);
    assertEquals("2012-12-02T12:45:00+08:00", DateTimes.toStringWithTimeZone(((DateTimeValue) value1).getValue()));
}
Also used : LinkedHashSet(java.util.LinkedHashSet) DateTimeValue(com.google.api.ads.admanager.axis.v202108.DateTimeValue) DateValue(com.google.api.ads.admanager.axis.v202108.DateValue) TargetingValue(com.google.api.ads.admanager.axis.v202108.TargetingValue) DateTimeValue(com.google.api.ads.admanager.axis.v202108.DateTimeValue) BooleanValue(com.google.api.ads.admanager.axis.v202108.BooleanValue) TextValue(com.google.api.ads.admanager.axis.v202108.TextValue) Value(com.google.api.ads.admanager.axis.v202108.Value) SetValue(com.google.api.ads.admanager.axis.v202108.SetValue) NumberValue(com.google.api.ads.admanager.axis.v202108.NumberValue) SetValue(com.google.api.ads.admanager.axis.v202108.SetValue) DateTime(com.google.api.ads.admanager.axis.v202108.DateTime) Test(org.junit.Test)

Example 73 with Value

use of com.google.firestore.v1beta1.Value in project structr by structr.

the class SessionTransaction method getStrings.

public Iterable<String> getStrings(final String statement, final Map<String, Object> map) {
    try {
        logQuery(statement, map);
        final StatementResult result = tx.run(statement, map);
        final Record record = result.next();
        final Value value = record.get(0);
        return new IteratorWrapper<>(value.asList(Values.ofString()).iterator());
    } catch (TransientException tex) {
        closed = true;
        throw new RetryException(tex);
    } catch (NoSuchRecordException nex) {
        throw new NotFoundException(nex);
    } catch (ServiceUnavailableException ex) {
        throw new NetworkException(ex.getMessage(), ex);
    } catch (DatabaseException dex) {
        throw SessionTransaction.translateDatabaseException(dex);
    } catch (ClientException cex) {
        throw SessionTransaction.translateClientException(cex);
    }
}
Also used : StatementResult(org.neo4j.driver.v1.StatementResult) TransientException(org.neo4j.driver.v1.exceptions.TransientException) Value(org.neo4j.driver.v1.Value) NotFoundException(org.structr.api.NotFoundException) Record(org.neo4j.driver.v1.Record) ServiceUnavailableException(org.neo4j.driver.v1.exceptions.ServiceUnavailableException) UnknownClientException(org.structr.api.UnknownClientException) ClientException(org.neo4j.driver.v1.exceptions.ClientException) RetryException(org.structr.api.RetryException) NetworkException(org.structr.api.NetworkException) UnknownDatabaseException(org.structr.api.UnknownDatabaseException) DatabaseException(org.neo4j.driver.v1.exceptions.DatabaseException) NoSuchRecordException(org.neo4j.driver.v1.exceptions.NoSuchRecordException)

Example 74 with Value

use of com.google.firestore.v1beta1.Value in project structr by structr.

the class RecordRelationshipMapper method apply.

@Override
public Relationship apply(final Record record) {
    // target node present?
    final Value t = record.get("t");
    if (!t.isNull()) {
        NodeWrapper.newInstance(db, t.asNode());
    }
    // source node present?
    final Value s = record.get("s");
    if (!s.isNull()) {
        NodeWrapper.newInstance(db, s.asNode());
    }
    // "other" node present (direction unknown)?
    final Value o = record.get("o");
    if (!o.isNull()) {
        NodeWrapper.newInstance(db, o.asNode());
    }
    return record.get(0).asRelationship();
}
Also used : Value(org.neo4j.driver.v1.Value)

Example 75 with Value

use of com.google.firestore.v1beta1.Value in project firebase-android-sdk by firebase.

the class SQLiteIndexManager method computeIndexEntries.

/**
 * Creates the index entries for the given document.
 */
private SortedSet<IndexEntry> computeIndexEntries(Document document, FieldIndex fieldIndex) {
    SortedSet<IndexEntry> result = new TreeSet<>();
    @Nullable byte[] directionalValue = encodeDirectionalElements(fieldIndex, document);
    if (directionalValue == null) {
        return result;
    }
    @Nullable FieldIndex.Segment arraySegment = fieldIndex.getArraySegment();
    if (arraySegment != null) {
        Value value = document.getField(arraySegment.getFieldPath());
        if (isArray(value)) {
            for (Value arrayValue : value.getArrayValue().getValuesList()) {
                result.add(IndexEntry.create(fieldIndex.getIndexId(), document.getKey(), encodeSingleElement(arrayValue), directionalValue));
            }
        }
    } else {
        result.add(IndexEntry.create(fieldIndex.getIndexId(), document.getKey(), new byte[] {}, directionalValue));
    }
    return result;
}
Also used : FieldIndex(com.google.firebase.firestore.model.FieldIndex) TreeSet(java.util.TreeSet) Value(com.google.firestore.v1.Value) IndexEntry(com.google.firebase.firestore.index.IndexEntry) Nullable(androidx.annotation.Nullable)

Aggregations

Test (org.junit.Test)126 Value (com.google.firestore.v1.Value)108 ArrayValue (com.google.firestore.v1.ArrayValue)73 LinkedHashSet (java.util.LinkedHashSet)71 ObjectValue (com.google.firebase.firestore.model.ObjectValue)53 NullValue (com.google.protobuf.NullValue)50 MapValue (com.google.firestore.v1.MapValue)47 ArrayList (java.util.ArrayList)30 HashMap (java.util.HashMap)25 Value (com.google.datastore.v1.Value)20 Map (java.util.Map)20 TableFieldSchema (com.google.api.services.bigquery.model.TableFieldSchema)17 List (java.util.List)17 Record (org.apache.avro.generic.GenericData.Record)16 SchemaAndRecord (org.apache.beam.sdk.io.gcp.bigquery.SchemaAndRecord)16 CoreMatchers.notNullValue (org.hamcrest.CoreMatchers.notNullValue)16 Set (java.util.Set)14 TestUtil.wrapObject (com.google.firebase.firestore.testutil.TestUtil.wrapObject)13 Nullable (androidx.annotation.Nullable)10 Value (com.google.privacy.dlp.v2.Value)9