package com.bocloud.ims.interfaces.topology;

import com.bocloud.common.model.BocloudResult;
import com.bocloud.ims.entity.topology.*;

import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.DelayQueue;

/**
 * InstanceRelation Service层
 *
 * @author lyy
 * @Version 1.0
 * @since 2017年9月15日
 */
public interface InstanceRelationService {

    /**
     * 实例关系列表展示
     *
     * @param id
     * @param userId
     * @param categoryId
     * @return
     */
    public BocloudResult list(Long id, Long userId, Long categoryId);

    /**
     * 关系保存
     *
     * @param id
     * @param links
     * @param userId
     * @param categoryId
     * @return
     */
    public BocloudResult create(Long id, List<Map<String, Long>> links, Long userId, Long categoryId);

    /**
     * 多维度保存
     *
     * @param list
     * @param userId
     * @return
     */
    public BocloudResult save(List<Object> list, Long userId, Long instanceId);

    /**
     * 处理关系
     *
     * @param relation
     * @param instance
     * @param moduleId
     * @param userId
     * @param relationDelayQueue
     * @param oldMap
     * @param insertRelationSet
     */
    public void syncRelation4Mq(List<InstanceRelationMq> relation, Instance instance, Long moduleId, Long userId,
                                DelayQueue<RelationDelay> relationDelayQueue, Map<String, InstanceRelation> oldMap,
                                Set<String> insertRelationSet);

    /**
     * 实例关系拓扑图
     *
     * @param id
     * @param categoryId
     * @param managerId
     * @param oneLevel
     * @param x
     * @param y
     * @param isGenerate
     * @return
     */
    public BocloudResult topology(Long id, Long categoryId, Long managerId, Boolean oneLevel, String x, String y, Boolean isGenerate);

    public BocloudResult tree(Long id, Long categoryId, Long managerId);

    /**
     * 实例关系拓扑坐标设置
     *
     * @param instanceLocation
     * @return
     */
    public BocloudResult location(InstanceLocation instanceLocation);

    public BocloudResult topology(Long nodeId, String uuid, Long categoryId, Long managerId, Boolean oneLevel, String x, String y, Boolean isGenerate);

    /**
     * 关系的自动维护
     *
     * @param instance
     * @param userId
     */
    public void autoDiscovery(Instance instance, Long userId);

    /**
     * 关系校验
     *
     * @param moduleRelation
     * @param one
     * @param two
     * @return
     * @throws Exception
     */
    public BocloudResult validate(ModuleRelation moduleRelation, Instance one, Instance two) throws Exception;
}
