@Override
 public Treaty getTreaty() {
   if (treaty == null || treaty.isEmpty()) {
     throw new InvalidValueException(
         String.format("'treaty' property cannot be null (Affected site with ID:%s)", id));
   }
   return Treaty.getTreaty(treaty);
 }
  /**
   * Build the schema metadata for this object
   *
   * @param namespace Namespace to place this entity into
   * @return Schema used by the producer to declare entities into the metadata document
   */
  public static EdmSchema getSchema(String namespace) {
    List<EdmEntitySet> entitySets = new ArrayList<EdmEntitySet>();
    List<EdmEntityType> entityTypes = new ArrayList<EdmEntityType>();

    // Define contact entity
    EdmEntityType eet = getEntityType(namespace);
    EdmEntitySet ees = new EdmEntitySet(COLLECTION_NAME, eet);
    entitySets.add(ees);
    entityTypes.add(eet);

    ////////////////////////////////////////////////////////////////////////////// Define treaties
    // navigable property
    String propertyName = NAV_PROP_TREATIES;

    EdmEntityType eetTreaty = Treaty.getEntityType(namespace);
    entityTypes.add(eetTreaty);
    EdmEntitySet eesTreaty = new EdmEntitySet(propertyName, eetTreaty);
    entitySets.add(eesTreaty);

    String assocName = String.format("FK_%s_%s", propertyName, COLLECTION_NAME);
    EdmAssociation assoc1 =
        new EdmAssociation(
            namespace,
            null,
            assocName,
            new EdmAssociationEnd(COLLECTION_NAME, eet, EdmMultiplicity.ZERO_TO_ONE),
            new EdmAssociationEnd(propertyName, eetTreaty, EdmMultiplicity.MANY));

    List<EdmAssociationSet> lAssoc = new ArrayList<EdmAssociationSet>();
    lAssoc.add(
        new EdmAssociationSet(
            assocName,
            assoc1,
            new EdmAssociationSetEnd(
                new EdmAssociationEnd(COLLECTION_NAME, eet, EdmMultiplicity.ZERO_TO_ONE), ees),
            new EdmAssociationSetEnd(
                new EdmAssociationEnd(propertyName, eetTreaty, EdmMultiplicity.MANY), eesTreaty)));

    EdmNavigationProperty np =
        new EdmNavigationProperty(propertyName, assoc1, assoc1.end1, assoc1.end2);
    eet.navigationProperties.add(np);

    // Output everything
    EdmEntityContainer container =
        new EdmEntityContainer("InforMEAService", true, null, entitySets, lAssoc, null);
    List<EdmEntityContainer> containers = new ArrayList<EdmEntityContainer>();
    containers.add(container);

    return new EdmSchema(
        namespace, null, entityTypes, null, Enumerable.create(assoc1).toList(), containers);
  }