package com.libreecm.db.jpa;

import java.util.List;
import java.util.Map;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Transient;

import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Type;

import com.libreecm.db.jpa.properties.PropertyDefinition;
 
@Entity
public class ObjectType{

	@Id
	@GeneratedValue(generator="hilo-gen")
	@GenericGenerator(name="hilo-gen", strategy="hilo")
	private Integer id;

	/**
	 * 
	 */
	@Transient
	private static final long serialVersionUID = 1L;

	@OneToMany
	private List<CmisExtensionElementImpl> extensions;
	
	private String localName;

	private String localNamespace;

	private String displayName;

	private String queryName;

	private String description;

	private BaseTypeId baseTypeId;

	private String parentTypeId;

	private Boolean creatable;

	private Boolean fileable;

	private Boolean queryable;

	private Boolean fullTextIndexed;

	private Boolean includedInSupertypeQuery;

	private Boolean controllablePolicy;

	private Boolean controllableAcl;
	
	private String repositoryName;

	@Type(type="com.libreecm.db.jpa.TypeMutability")
	@ManyToOne
	private TypeMutability typeMutability;
	
	@OneToMany
	private Map<String, PropertyDefinition<?>> propertyDefinitions;

	public ObjectType(){
	}
	
	public List<CmisExtensionElementImpl> getExtensions() {
		return extensions;
	}

	public void setExtensions(List<CmisExtensionElementImpl> extensions) {
		this.extensions=extensions;
	}

	public String getId() {
		if (id==null)
			return null;
		return id.toString();
	}

	public String getLocalName() {
		return localName;
	}

	public String getLocalNamespace() {
		return localNamespace;
	}

	public String getDisplayName() {
		return displayName;
	}

	public String getQueryName() {
		return queryName;
	}

	public String getDescription() {
		return description;
	}

	public BaseTypeId getBaseTypeId() {
		return baseTypeId;
	}

	public String getParentTypeId() {
		return parentTypeId;
	}

	public Boolean isCreatable() {
		return creatable;
	}

	public Boolean isFileable() {
		return fileable;
	}

	public Boolean isQueryable() {
		return queryable;
	}

	public Boolean isFulltextIndexed() {
		return fullTextIndexed;
	}

	public Boolean isIncludedInSupertypeQuery() {
		return includedInSupertypeQuery;
	}

	public Boolean isControllablePolicy() {
		return controllablePolicy;
	}

	public Boolean isControllableAcl() {
		return controllableAcl;
	}

	public Map<String, PropertyDefinition<?>> getPropertyDefinitions() {
		return propertyDefinitions;
	}

	public TypeMutability getTypeMutability() {
		return typeMutability;
	}

	
	/**
	 * @param id the id to set
	 */
	public void setId(Integer id) {
		this.id = id;
	}

	/**
	 * @param localName the localName to set
	 */
	public void setLocalName(String localName) {
		this.localName = localName;
	}

	/**
	 * @param localNamespace the localNamespace to set
	 */
	public void setLocalNamespace(String localNamespace) {
		this.localNamespace = localNamespace;
	}

	/**
	 * @param displayName the displayName to set
	 */
	public void setDisplayName(String displayName) {
		this.displayName = displayName;
	}

	/**
	 * @param queryName the queryName to set
	 */
	public void setQueryName(String queryName) {
		this.queryName = queryName;
	}

	/**
	 * @param description the description to set
	 */
	public void setDescription(String description) {
		this.description = description;
	}

	/**
	 * @param baseTypeId the baseTypeId to set
	 */
	public void setBaseTypeId(BaseTypeId baseTypeId) {
		this.baseTypeId = baseTypeId;
	}

	/**
	 * @param parentTypeId the parentTypeId to set
	 */
	public void setParentTypeId(String parentTypeId) {
		this.parentTypeId = parentTypeId;
	}

	/**
	 * @param propertyDefinitions the propertyDefinitions to set
	 */
	public void setPropertyDefinitions(Map<String, PropertyDefinition<?>> propertyDefinitions) {
		this.propertyDefinitions = propertyDefinitions;
	}

	/**
	 * @param typeMutability the typeMutability to set
	 */
	public void setTypeMutability(TypeMutability typeMutability) {
		this.typeMutability = typeMutability;
	}

	public String getRepositoryName() {
		return repositoryName;
	}

	public void setRepositoryName(String repositoryName) {
		this.repositoryName = repositoryName;
	}
	
}
