package com.libreecm.commonAPI.model.objects;

import java.util.ArrayList;
import java.util.List;

import com.libreecm.commonAPI.model.enums.BaseTypeId;
import com.libreecm.commonAPI.model.enums.Cardinality;
import com.libreecm.commonAPI.model.enums.PropertyType;
import com.libreecm.commonAPI.model.enums.Updatability;
import com.libreecm.commonAPI.model.objects.properties.PropertyStringDefinitionImpl;

public class RelationshipObjectType extends ObjectType {

	private List<String> allowedTargetTypeIds;
	private List<String> allowedSourceTypeIds;

	public RelationshipObjectType() {
		super();
		List<String> contents=new ArrayList<>();
		for (ContentStreamAllowed content: ContentStreamAllowed.values()){
			contents.add(content.value());
		}
		Choice<String> choice = new Choice<String>();
		choice.setDisplayName("Content Stream Allowed Types");
		choice.setValue(contents);
		List<Choice<String>> choices = new ArrayList<>();
		choices.add(choice);
		
		
		List<Boolean> defaultBooleanTrue=new ArrayList<>();
		defaultBooleanTrue.add(true);
		
		List<Choice<Boolean>> boolChoices = new ArrayList<>();
		Choice<Boolean> boolChoice = new Choice<Boolean>();
		boolChoice.setDisplayName("Boolean");

		List<Boolean> defaultBooleans=new ArrayList<>();
		defaultBooleans.add(true);
		defaultBooleans.add(false);
		
		boolChoice.setValue(defaultBooleans);
		boolChoices.add(boolChoice);
		super.getPropertyDefinitions().put("cmis:allowedTargetTypeIds",new PropertyStringDefinitionImpl					("Allowed Target Type Ids","cmis:allowedTargetTypeIds","Allowed Target Type Ids","","cmis:allowedTargetTypeIds","cmis:allowedTargetTypeIds",								PropertyType.STRING,Cardinality.SINGLE,Updatability.READONLY,			true,false,false,false,						new ArrayList<String>(),true,new ArrayList<Choice<String>>()));
		super.getPropertyDefinitions().put("cmis:allowedSourceTypeIds",new PropertyStringDefinitionImpl					("Allowed Source Type Ids","cmis:allowedSourceTypeIds","Allowed Source Type Ids","","cmis:allowedSourceTypeIds","cmis:allowedSourceTypeIds",								PropertyType.STRING,Cardinality.SINGLE,Updatability.READONLY,			true,false,false,false,						new ArrayList<String>(),true,new ArrayList<Choice<String>>()));

		this.setId(BaseTypeId.CMIS_RELATIONSHIP.value());
		this.setBaseTypeId(BaseTypeId.CMIS_RELATIONSHIP);
		this.setParentTypeId(BaseTypeId.CMIS_RELATIONSHIP.value());
	}

	public List<String> getAllowedTargetTypeIds() {
		return allowedTargetTypeIds;
	}

	public List<String> getAllowedSourceTypeIds() {
		return allowedSourceTypeIds;
	}

	/**
	 * @param allowedTargetTypeIds the allowedTargetTypeIds to set
	 */
	public void setAllowedTargetTypeIds(List<String> allowedTargetTypeIds) {
		if (allowedTargetTypeIds==null||allowedTargetTypeIds.size()==0) return;
		addStringProperty("cmis:allowedTargetTypeIds",allowedTargetTypeIds);
		this.allowedTargetTypeIds = allowedTargetTypeIds;
	}

	/**
	 * @param allowedSourceTypeIds the allowedSourceTypeIds to set
	 */
	public void setAllowedSourceTypeIds(List<String> allowedSourceTypeIds) {
		if (allowedSourceTypeIds==null||allowedSourceTypeIds.size()==0) return;
		addStringProperty("cmis:allowedSourceTypeIds",allowedSourceTypeIds);
		this.allowedSourceTypeIds = allowedSourceTypeIds;
	}
}
