/*
 * Copyright 2014 Open mHealth
 *
 * Licensed 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.openmhealth.dsu.domain;

import java.util.Optional;


/**
 * The metadata of a data point.
 *
 * @author Emerson Farrugia
 */
public class DataPointMetadata {

    private String id;
    private String schemaName;
    private String schemaVersion;
    private DataPointAcquisitionProvenance acquisitionProvenance;

    /**
     * @param id the globally unique identifier of the data point
     * @param schemaName the name of the schema the data point conforms to
     * @param schemaVersion the version of the schema the data point conforms to
     */
    public DataPointMetadata(String id, String schemaName, String schemaVersion) {

        this.id = id;
        this.schemaName = schemaName;
        this.schemaVersion = schemaVersion;
    }

    public String getId() {
        return id;
    }

    public String getSchemaName() {
        return schemaName;
    }

    public String getSchemaVersion() {
        return schemaVersion;
    }

    /**
     * @return the acquisition provenance of the data point
     */
    public Optional<DataPointAcquisitionProvenance> getAcquisitionProvenance() {
        return Optional.ofNullable(acquisitionProvenance);
    }

    public void setAcquisitionProvenance(DataPointAcquisitionProvenance acquisitionProvenance) {
        this.acquisitionProvenance = acquisitionProvenance;
    }
}

@@ -638,25 +638,238 @@
 ort 
-java.util.Optiona
+org.openmhealth.schema.domain.SchemaId;%0A%0Aimport java.time.OffsetDateTime;%0Aimport java.util.Optional;%0A%0Aimport static com.google.common.base.Preconditions.checkArgument;%0Aimport static com.google.common.base.Preconditions.checkNotNul
 l;%0A%0A
@@ -1011,32 +1011,32 @@
 rivate S
-tring
+chemaId
  schema
-Name
+Id
 ;%0A    pr
@@ -1041,36 +1041,48 @@
 private 
-String schemaVersion
+OffsetDateTime creationTimestamp
 ;%0A    pr
@@ -1175,24 +1175,8 @@
 the 
-globally unique 
 iden
@@ -1224,21 +1224,25 @@
 hema
-Name
+Id
  the 
-name
+identifier
  of 
@@ -1289,173 +1289,575 @@
    *
- @param schemaVersion the version of the schema the data point conforms to%0A     */%0A    public DataPointMetadata(String id, String schemaName, String schemaVersion) %7B
+/%0A    public DataPointMetadata(String id, SchemaId schemaId) %7B%0A%0A        this(id, schemaId, OffsetDateTime.now());%0A    %7D%0A%0A    /**%0A     * @param id the identifier of the data point%0A     * @param schemaId the identifier of the schema the data point conforms to%0A     * @param creationTimestamp the creation time of this data point%0A     */%0A    public DataPointMetadata(String id, SchemaId schemaId, OffsetDateTime creationTimestamp) %7B%0A%0A        checkNotNull(id);%0A        checkArgument(!id.isEmpty());%0A        checkNotNull(schemaId);%0A        checkNotNull(creationTimestamp);
 %0A%0A  
@@ -1895,20 +1895,18 @@
 s.schema
-Name
+Id
  = schem
@@ -1902,28 +1902,26 @@
 aId = schema
-Name
+Id
 ;%0A        th
@@ -1927,37 +1927,45 @@
 his.
-schemaVersion = schemaVersion
+creationTimestamp = creationTimestamp
 ;%0A  
@@ -2027,37 +2027,39 @@
  %7D%0A%0A    public S
-tring
+chemaId
  getSchemaName()
@@ -2052,20 +2052,18 @@
 etSchema
-Name
+Id
 () %7B%0A   
@@ -2084,12 +2084,10 @@
 hema
-Name
+Id
 ;%0A  
@@ -2106,31 +2106,43 @@
 lic 
-String getSchemaVersion
+OffsetDateTime getCreationTimestamp
 () %7B
@@ -2161,21 +2161,25 @@
 urn 
-schemaVersion
+creationTimestamp
 ;%0A  

Update data point metadata to use schema IDs.