All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.shindig.social.opensocial.jpa.AddressDb Maven / Gradle / Ivy

Go to download

Provides Sample implementations of the SPI and API's inside the core of Shindig.

There is a newer version: 3.0.0-beta4
Show newest version
/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements. See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License. You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations under the License.
 */
package org.apache.shindig.social.opensocial.jpa;

import static javax.persistence.GenerationType.IDENTITY;

import org.apache.shindig.social.opensocial.jpa.api.DbObject;
import org.apache.shindig.social.opensocial.model.Address;
import org.apache.shindig.social.opensocial.model.Person;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Version;

import java.util.List;

/**
 * Address storage, stored in "address", may be joined with other subclasses and if so
 * "address_usage" will contain the subclass discriminatory value. 
 * This might also be "sharedaddress" if this address is shared.
 */
@Entity
@Table(name = "address")
@Inheritance(strategy = InheritanceType.JOINED)
@DiscriminatorColumn(name = "address_usage")
@DiscriminatorValue(value = "sharedaddress")
@NamedQuery(name = AddressDb.FINDBY_POSTCODE, 
    query = "select a from AddressDb a where a.postalCode = :postalcode ")
public class AddressDb implements Address, DbObject {
  /**
   * Name of the JPA query to find addresses by postcode
   */
  public static final String FINDBY_POSTCODE = "q.address.findbypostcode";

  /**
   * name of the postcode parameter used in named queries (JPA)
   */
  public static final String PARAM_POSTCODE = "postalcode";

  /**
   * The internal object ID used for references to this object. Should be generated by the
   * underlying storage mechanism
   */
  @Id
  @GeneratedValue(strategy = IDENTITY)
  @Column(name = "oid")
  private long objectId;

  /**
   * An optimistic locking field
   */
  @Version
  @Column(name = "version")
  protected long version;

  /**
   * People may be at this address, this is a list of people who are currently at this address.
   */
  @OneToMany(targetEntity = PersonDb.class, mappedBy = "currentLocation")
  private List atLocation;

  /**
   * model field.
   * @see org.apache.shindig.social.opensocial.model.Address
   */
  @Basic
  @Column(name = "country", length = 255)
  private String country;

  /**
   * model field.
   * @see org.apache.shindig.social.opensocial.model.Address
   */
  @Basic
  @Column(name = "latitude")
  private Float latitude;

  /**
   * model field.
   * @see org.apache.shindig.social.opensocial.model.Address
   */
  @Basic
  @Column(name = "longitude")
  private Float longitude;

  /**
   * model field.
   * @see org.apache.shindig.social.opensocial.model.Address
   */
  @Basic
  @Column(name = "locality", length = 255)
  private String locality;

  /**
   * model field.
   * @see org.apache.shindig.social.opensocial.model.Address
   */
  @Basic
  @Column(name = "postal_code", length = 255)
  private String postalCode;

  /**
   * model field.
   * @see org.apache.shindig.social.opensocial.model.Address
   */
  @Basic
  @Column(name = "region", length = 255)
  private String region;

  /**
   * model field.
   * @see org.apache.shindig.social.opensocial.model.Address
   */
  @Basic
  @Column(name = "street_address", length = 255)
  private String streetAddress;

  /**
   * model field.
   * @see org.apache.shindig.social.opensocial.model.Address
   */
  @Basic
  @Column(name = "type", length = 255)
  private String type;

  /**
   * model field.
   * @see org.apache.shindig.social.opensocial.model.Address
   */
  @Basic
  @Column(name = "formatted", length = 255)
  private String formatted;

  /**
   * model field.
   * @see org.apache.shindig.social.opensocial.model.Address
   */
  @Basic
  @Column(name = "primary_address")
  private Boolean primary;

  /**
   *  default constructor
   */
  public AddressDb() {
  }

  /**
   * Create an address from the formatted address, no parsing of the address will be performed.
   * @param formatted the formatted address.
   */
  public AddressDb(String formatted) {
    this.formatted = formatted;
  }

  /** 
   * {@inheritDoc}
   * @see org.apache.shindig.social.opensocial.model.Address#getCountry()
   */
  public String getCountry() {
    return country;
  }

  /** 
   * {@inheritDoc}
   * @see org.apache.shindig.social.opensocial.model.Address#setCountry(java.lang.String)
   */
  public void setCountry(String country) {
    this.country = country;
  }

  /** 
   * {@inheritDoc}
   * @see org.apache.shindig.social.opensocial.model.Address#getLatitude()
   */
  public Float getLatitude() {
    return latitude;
  }

  /** 
   * {@inheritDoc}
   * @see org.apache.shindig.social.opensocial.model.Address#setLatitude(java.lang.Float)
   */
  public void setLatitude(Float latitude) {
    this.latitude = latitude;
  }

  /** 
   * {@inheritDoc}
   * @see org.apache.shindig.social.opensocial.model.Address#getLocality()
   */
  public String getLocality() {
    return locality;
  }

  /** 
   * {@inheritDoc}
   * @see org.apache.shindig.social.opensocial.model.Address#setLocality(java.lang.String)
   */
  public void setLocality(String locality) {
    this.locality = locality;
  }

  /** 
   * {@inheritDoc}
   * @see org.apache.shindig.social.opensocial.model.Address#getLongitude()
   */
  public Float getLongitude() {
    return longitude;
  }

  /** 
   * {@inheritDoc}
   * @see org.apache.shindig.social.opensocial.model.Address#setLongitude(java.lang.Float)
   */
  public void setLongitude(Float longitude) {
    this.longitude = longitude;
  }

  /** 
   * {@inheritDoc}
   * @see org.apache.shindig.social.opensocial.model.Address#getPostalCode()
   */
  public String getPostalCode() {
    return postalCode;
  }

  /** 
   * {@inheritDoc}
   * @see org.apache.shindig.social.opensocial.model.Address#setPostalCode(java.lang.String)
   */
  public void setPostalCode(String postalCode) {
    this.postalCode = postalCode;
  }

  /** 
   * {@inheritDoc}
   * @see org.apache.shindig.social.opensocial.model.Address#getRegion()
   */
  public String getRegion() {
    return region;
  }

  /** 
   * {@inheritDoc}
   * @see org.apache.shindig.social.opensocial.model.Address#setRegion(java.lang.String)
   */
  public void setRegion(String region) {
    this.region = region;
  }

  /** 
   * {@inheritDoc}
   * @see org.apache.shindig.social.opensocial.model.Address#getStreetAddress()
   */
  public String getStreetAddress() {
    return streetAddress;
  }

  /** 
   * {@inheritDoc}
   * @see org.apache.shindig.social.opensocial.model.Address#setStreetAddress(java.lang.String)
   */
  public void setStreetAddress(String streetAddress) {
    this.streetAddress = streetAddress;
  }

  /** 
   * {@inheritDoc}
   * @see org.apache.shindig.social.opensocial.model.Address#getType()
   */
  public String getType() {
    return type;
  }

  /** 
   * {@inheritDoc}
   * @see org.apache.shindig.social.opensocial.model.Address#setType(java.lang.String)
   */
  public void setType(String type) {
    this.type = type;
  }

  /** 
   * {@inheritDoc}
   * @see org.apache.shindig.social.opensocial.model.Address#getFormatted()
   */
  public String getFormatted() {
    return formatted;
  }

  /** 
   * {@inheritDoc}
   * @see org.apache.shindig.social.opensocial.model.Address#setFormatted(java.lang.String)
   */
  public void setFormatted(String formatted) {
    this.formatted = formatted;
  }

  /** 
   * {@inheritDoc}
   * @see org.apache.shindig.social.opensocial.model.Address#getPrimary()
   */
  public Boolean getPrimary() {
    return primary;
  }

  /** 
   * {@inheritDoc}
   * @see org.apache.shindig.social.opensocial.model.Address#setPrimary(java.lang.Boolean)
   */
  public void setPrimary(Boolean primary) {
    this.primary = primary;
  }

  /**
   * @return the objectId
   */
  public long getObjectId() {
    return objectId;
  }

  /**
   * @return the atLocation
   */
  public List getAtLocation() {
    return atLocation;
  }

  /**
   * @param atLocation the atLocation to set
   */
  public void setAtLocation(List atLocation) {
    this.atLocation = atLocation;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy