Package com.google.storage.onestore.v3.OnestoreEntity

Examples of com.google.storage.onestore.v3.OnestoreEntity.PropertyValue


    public void refereceToKeyForName() throws Exception {
        Key key = KeyFactory.createKey("Hoge", "aaa");
        Reference reference = new Reference();
        Path path = new Path();
        reference.setPath(path);
        Element element = path.addElement();
        element.setType("Hoge");
        element.setName("aaa");
        assertThat(DatastoreUtil.referenceToKey(reference), is(key));
    }
View Full Code Here


        Key parentKey = KeyFactory.createKey("Parent", 1);
        Key childKey = KeyFactory.createKey(parentKey, "Child", 1);
        Reference reference = new Reference();
        Path path = new Path();
        reference.setPath(path);
        Element element = path.addElement();
        element.setType("Parent");
        element.setId(1);
        element = path.addElement();
        element.setType("Child");
        element.setId(1);
        assertThat(DatastoreUtil.referenceToKey(reference), is(childKey));
    }
View Full Code Here

   * @param multiple whether this property has multiple values
   * @param entity the entity to populate
   */
  private static void addPropertyToPb(String name, Object value, boolean indexed, boolean multiple,
      EntityProto entity) {
    Property property = new Property();
    property.setName(name);
    property.setMultiple(multiple);
    PropertyValue newValue = property.getMutableValue();
    if (value != null) {
      Type<?> type = getType(value.getClass());
      Meaning meaning = type.getV3Meaning();
      if (meaning != property.getMeaningEnum()) {
        property.setMeaning(meaning);
      }
      indexed &= type.toV3Value(value, newValue);
    }
    if (!indexed) {
      entity.addRawProperty(property);
View Full Code Here

  private static Iterable<Property> getImplicitProperties(EntityProto proto) {
    return Collections.singleton(buildImplicitKeyProperty(proto));
  }

  private static Property buildImplicitKeyProperty(EntityProto proto) {
    Property keyProp = new Property();
    keyProp.setName(Entity.KEY_RESERVED_PROPERTY);
    PropertyValue propVal = new PropertyValue();
    propVal.setReferenceValue(KeyType.toReferenceValue(proto.getKey()));
    keyProp.setValue(propVal);
    return keyProp;
  }
View Full Code Here

   */
  private static void addProperty(EntityProto entity, String name, Object value,
                                  boolean indexed, boolean multiple) {
    Pair<Type<?>, Property> pair = createProperty(name, value, multiple);
    Type<?> type = pair.first();
    Property property = pair.second();

    if (!indexed || (type != null && type.getComparableFunction() == NOT_COMPARABLE)) {
      entity.addRawProperty(property);
    } else {
      entity.addProperty(property);
View Full Code Here

   * @return a not {@code null} Pair<Type, Property>. The {@code Type} will be null
   * iff {@code value} is null. {@code Property} will not be null.
   */
  private static Pair<Type<?>, Property> createProperty(String name, Object value,
      boolean multiple) {
    Property property = new Property();
    property.setName(name);
    property.setMultiple(multiple);

    if (value == null) {
      return Pair.of(null, property);
    }

    Pair<Type<?>, PropertyValue> newValue = createPropertyValue(value);
    Type<?> type = newValue.first;
    Meaning meaning = type.getMeaning();
    if (meaning != Meaning.NO_MEANING) {
      property.setMeaning(meaning);
    }
    property.setValue(newValue.second);
    return new Pair<Type<?>, Property>(type, property);
  }
View Full Code Here

  private static Iterable<Property> getImplicitProperties(EntityProto proto) {
    return Collections.singleton(buildImplicitKeyProperty(proto));
  }

  private static Property buildImplicitKeyProperty(EntityProto proto) {
    Property keyProp = new Property();
    keyProp.setName(Entity.KEY_RESERVED_PROPERTY);
    PropertyValue propVal = new PropertyValue();
    ReferenceType.setPropertyValue(propVal, proto.getKey());
    keyProp.setValue(propVal);
    return keyProp;
  }
View Full Code Here

      EntityProto proto, String propertyName) {
    if (propertyName.equals(Entity.KEY_RESERVED_PROPERTY)) {
      return Collections.singleton(buildImplicitKeyProperty(proto));
    }
    Collection<Property> multipleProps = new ArrayList<Property>();
    Property singleProp = addPropertiesWithName(proto.propertys(), propertyName, multipleProps);
    if (singleProp != null) {
      return Collections.singleton(singleProp);
    }
    return multipleProps;
  }
View Full Code Here

      while (i.hasNext()) {
        cost += 25;
        EntityProto ep = i.next();
        Iterator<Property> pi = ep.propertyIterator();
        while (pi.hasNext()) {
          Property p = pi.next();
          Meaning m = p.getMeaningEnum();
          if (m != null) {
            if (m.compareTo(Meaning.BLOB) != 0
                && m.compareTo(Meaning.TEXT) != 0) {
              cost += 20;
            }
View Full Code Here

      while (i.hasNext()) {
        cost += 25;
        EntityProto ep = i.next();
        Iterator<Property> pi = ep.propertyIterator();
        while (pi.hasNext()) {
          Property p = pi.next();
          Meaning m = p.getMeaningEnum();
          if (m != null) {
            if (m.compareTo(Meaning.BLOB) != 0
                && m.compareTo(Meaning.TEXT) != 0) {
              cost += 20;
            }
View Full Code Here

TOP

Related Classes of com.google.storage.onestore.v3.OnestoreEntity.PropertyValue

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.