package com.jeans.iservlet.view.it;

import com.jeans.iservlet.model.it.GenericProject;
import com.jeans.iservlet.model.it.Project;
import com.jeans.iservlet.model.it.Repository;
import com.jeans.iservlet.view.BaseView;

/**
 * 资料库概要信息视图类，提供字段：id, parent, parentId, repoType, repoTypeValue
 * 
 * @author Majorli
 *
 */
public class RepositoryView extends BaseView {
	protected String parent;
	protected Long parentId;
	protected String repoType;
	protected int repoTypeValue;

	protected RepositoryView(GenericProject prj) {
		super(prj);
	}

	@Override
	public GenericProject item() {
		return (GenericProject) item;
	}

	@Override
	public long getId() {
		return noItem() ? 0 : item().getRepository().getId();
	}

	public String getParent() {
		return noItem() ? null : item().getName();
	}

	public long getParentId() {
		return noItem() ? 0 : item().getId();
	}

	public String getRepoType() {
		return noItem() ? null : (item instanceof Project ? "信息化项目建设文档库" : "信息化系统运维文档库");
	}

	public int getRepoTypeValue() {
		return noItem() ? -1 : (item instanceof Project ? Repository.PROJECT_REPOSITORY : Repository.MAINTAIN_REPOSITORY);
	}
}
