/*
 * Copyright 2021 B2i Healthcare Pte Ltd, http://b2i.sg
 * 
 * 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 com.b2international.snowowl.core;

import java.io.Serializable;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonSetter;

/**
 * @since 8.0
 */
public abstract class Resource implements Serializable {

	private static final long serialVersionUID = 1L;

	// unique identifier for each resource, can be auto-generated or manually specified
	private String id;

	// URL, eg. http://snomed.info/sct
	private String url;

	// FHIR Property, human-readable name of the resource (formerly CodeSystem.name in 7.x)
	private String title;
	
	// FHIR Property, primary language of this resource, must be a valid two letter ISO-639 language code, if defined
	private String language;
	
	// FHIR Property, supports markdown
	private String description;

	// FHIR Property, publication status of the resource, usually draft|active|retired|unknown (maybe experimental, etc.)
	private String status;

	// FHIR Property, supports markdown
	private String copyright;

	// ('publisher' FHIR property, but owner is way better for our use cases)
	private String owner;

	// FHIR Property, primary e-mail address or contact URL (FHIR property)
	private String contact;

	// useContext from FHIR is just too complex for our initial use cases, using former usage field instead
	private String usage;
	
	// FHIR property, supports markdown
	private String purpose;

	/**
	 * @return the type of the resource
	 */
	@JsonIgnore
	public abstract String getResourceType();
	
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}
	
	public ResourceURI getResourceURI() {
		return ResourceURI.of(getResourceType(), getId());
	}

	// XXX empty setter to make Jackson happy when deserializing 
	@JsonSetter
	final void setResourceURI(ResourceURI resourceUri) {}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	/**
	 * @return the human-readable name of this resource, eg. "{@code SNOMED Clinical Terms}"
	 */
	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}
	
	/**
	 * The primary language tag of the resource, eg. "en_US"
	 * @return
	 */
	public String getLanguage() {
		return language;
	}
	
	public void setLanguage(String language) {
		this.language = language;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public String getCopyright() {
		return copyright;
	}

	public void setCopyright(String copyright) {
		this.copyright = copyright;
	}

	public String getOwner() {
		return owner;
	}

	public void setOwner(String owner) {
		this.owner = owner;
	}

	public String getContact() {
		return contact;
	}

	public void setContact(String contact) {
		this.contact = contact;
	}

	public String getUsage() {
		return usage;
	}

	public void setUsage(String usage) {
		this.usage = usage;
	}

	public String getPurpose() {
		return purpose;
	}

	public void setPurpose(String purpose) {
		this.purpose = purpose;
	}
	
}

@@ -2123,329 +2123,1261 @@
 %0A%09%0A%09
-public String getId() %7B%0A%09%09return id;%0A%09%7D%0A%0A%09public void setId(String id) %7B%0A%09%09this.id = id;%0A%09%7D%0A%09%0A%09public ResourceURI getResourceURI() %7B%0A%09%09return ResourceURI.of(getResourceType(), getId());%0A%09%7D%0A%0A%09// XXX empty setter to make Jackson happy when deserializing %0A%09@JsonSetter%0A%09final void setResourceURI(ResourceURI resourceUri) %7B%7D%0A
+/**%0A%09 * Logical id of this resource.%0A%09 * %0A%09 * The logical id on the system that holds the System resource instance - this typically is expected to change as the resource moves from server to server. %0A%09 * The location URI is constructed by appending the logical id to the server base address where the instance is found and the resource type. %0A%09 * This URI should be a resolvable URL by which the resource instance may be retrieved, usually from a server, and it may be a relative reference typically to the server base URL.%0A%09 * %0A%09 * @return%0A%09 */%0A%09public String getId() %7B%0A%09%09return id;%0A%09%7D%0A%0A%09public void setId(String id) %7B%0A%09%09this.id = id;%0A%09%7D%0A%09%0A%09public ResourceURI getResourceURI() %7B%0A%09%09return ResourceURI.of(getResourceType(), getId());%0A%09%7D%0A%0A%09// XXX empty setter to make Jackson happy when deserializing %0A%09@JsonSetter%0A%09final void setResourceURI(ResourceURI resourceUri) %7B%7D%0A%0A%09/**%0A%09 * The canonical URL that never changes for this resource - it is the same in every copy. This canonical URL is used to refer to all instances of%0A%09 * this particular code system across all servers and systems. Ideally, this URI should be a URL which resolves to the location of the master%0A%09 * version of the code system, though this is not always possible.%0A%09 * %0A%09 * @return%0A%09 */
 %0A%09pu

add documentation to id and url fields in Resource type