package com.yihu.hos.standard.controller;

import com.yihu.hos.web.framework.util.controller.BaseController;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * Created by LLH on 2016/1/6.
 */
@Controller
@RequestMapping("/integration")
public class IntegrationController extends BaseController {

    @RequestMapping("initial/standard")
    public String standardInitial(Model model) {
        model.addAttribute("type", 0);
        model.addAttribute("contentPage", "standard/integration/index");
        return "partView";
    }

    @RequestMapping("initial/application")
    public String applicationInitial(Model model) {
        model.addAttribute("type", 1);
        model.addAttribute("contentPage", "standard/integration/appIndex");
        return "partView";
    }

    @RequestMapping("standardUpdate")
    public String standardUpdate(Model model) {

        model.addAttribute("contentPage", "standard/integration/standardDetail");
        return "pageView";
    }

    @RequestMapping("publisherUpdate")
    public String publisherUpdate(Model model) {

        model.addAttribute("contentPage", "standard/integration/publisher");
        return "pageView";
    }

    @RequestMapping("versionUpdate")
    public String versionUpdate(Model model) {

        model.addAttribute("contentPage", "standard/integration/versionDetail");
        return "pageView";
    }

    @RequestMapping("copyVersion")
    public String copyVersion(Model model) {

        model.addAttribute("contentPage", "standard/integration/copyVersion");
        return "pageView";
    }

    @RequestMapping("configuration")
    public String configuration(Model model, String version, String stdId, Integer type,String status,String name) {
        model.addAttribute("version",version);
        stdId = stdId.replace("standard", "");
        if (type == 0) {
            model.addAttribute("backUrl", "/integration/initial/standard?treePid=5&treeId=21");
        } else if (type == 1) {
            model.addAttribute("backUrl", "/integration/initial/application?treePid=5&treeId=22");
        }
        model.addAttribute("stdId", Integer.parseInt(stdId));
        model.addAttribute("status",status);
        model.addAttribute("type",type);
        model.addAttribute("name",name);
        model.addAttribute("contentPage", "standard/integration/configuration");
        return "partView";
    }

    @RequestMapping("updateDataset")
    public String updateDataset(Model model, String type, String version, Integer id, Integer standardId) {
        model.addAttribute("type",type);
        model.addAttribute("stdVersion",version);
        model.addAttribute("datasetId", id);
        model.addAttribute("standardId", standardId);
        model.addAttribute("contentPage", "standard/integration/dataset/updateDataset");
        return "pageView";
    }

    @RequestMapping("updateMetadata")
    public String updateMetadata(Model model, String type, String version, Integer id, Integer pid, Integer standardId) {
        model.addAttribute("contentPage", "standard/integration/dataset/updateMetadata");
        model.addAttribute("type",type);
        model.addAttribute("stdVersion", version);
        model.addAttribute("standardId", standardId);
        model.addAttribute("datasetId", pid);
        model.addAttribute("metadataId", id);
        return "pageView";
    }

    @RequestMapping("updateDict")
    public String updateDict(Model model, String type, String version, Integer id, Integer standardId) {
        model.addAttribute("contentPage", "standard/integration/dict/updateDict");
        model.addAttribute("type",type);
        model.addAttribute("stdVersion",version);
        model.addAttribute("dictId", id);
        model.addAttribute("standardId", standardId);
        return "pageView";
    }

    @RequestMapping("updateDictEntry")
    public String updateDictEntry(Model model, String type, String version, Integer id, Integer pid, Integer standardId) {
        model.addAttribute("contentPage", "standard/integration/dict/updateDictEntry");
        model.addAttribute("type",type);
        model.addAttribute("stdVersion", version);
        model.addAttribute("standardId", standardId);
        model.addAttribute("dictId", pid);
        model.addAttribute("dictEntryId", id);
        return "pageView";
    }
    @RequestMapping("importData")
    public String importData(Model model,String version,Integer standardId) {
        model.addAttribute("contentPage", "standard/integration/importData");
        model.addAttribute("version", version);
        model.addAttribute("standardId", standardId);
        return "pageView";
    }
}

