package com.liangjian.dataplatform.member.entity.vo.datanodes;

import com.liangjian.dataplatform.member.constant.MetaCoreConstant;
import com.liangjian.dataplatform.member.entity.po.primary.MetaCore;
import org.springframework.stereotype.Component;

/**
 * @Author: 黄子奇
 * @Date: 2019/8/26 17:20
 */
@Component
public class PDMTransfer implements DataNodeTransfer<PDM> {
    @Override
    public boolean matchTypeKey(String key) {
        return key.equals(MetaCoreConstant.MODEL_PHYSICAL_MODEL) || key.equals(MetaCoreConstant.RELATION_TABLE);
    }

    @Override
    public DataNode transfer(MetaCore metaCore) {
        PDM pdm = new PDM(
                metaCore.getId(),
                metaCore.getPrtId(),
                metaCore.getName(),
                metaCore.getBizDomain(),
                metaCore.getMetaMdl(),
                true,
                metaCore.getCmt(),
                metaCore.getRemarks(),
                metaCore.getCrtDate(),
                metaCore.getLastUpdate(),
                metaCore.getCrtUser(),
                metaCore.getNamespace(),
                metaCore.getChName()
        );
        return pdm;
    }

    @Override
    public MetaCore reTransfer(MetaCore metaCore, PDM node) {
        metaCore.setPrtId(node.getPrtId());
        metaCore.setName(node.getName());
        metaCore.setBizDomain(node.getBizDomain());
        metaCore.setMetaMdl(node.getNodeType());
        metaCore.setCmt(node.getComment());
        metaCore.setLastUpdate(node.getLastUpdate());
        metaCore.setChName(node.getCnName());
        metaCore.setRemarks(node.getRemark());
        return metaCore;
    }
}
