All Downloads are FREE. Search and download functionalities are using the official Maven repository.

live.document.mavenplugin.method.EntityMethodMindMap4CallTree Maven / Gradle / Ivy

package live.document.mavenplugin.method;

import live.document.generator.model.CallNode;
import live.document.mavenplugin.docify.CustomMindMap4CallTree;
import live.document.plsqlscanner.PlSqlExplained;
import live.document.plsqlscanner.PlSqlObject;
import live.document.scanner.DbObjectTypeEnum;

import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;

public class EntityMethodMindMap4CallTree extends CustomMindMap4CallTree {
    protected Function> getEntityOperations;
    protected PlSqlExplained plSqlExplained;

    @Override
    protected String getSuffix(CallNode node) {
        if (getEntityOperations == null) {
            return super.getSuffix(node);
        }

        if (node.getDbOperation() != null && node.getDbOperation().getObjectType() == DbObjectTypeEnum.TABLE) {
            return super.getSuffix(node);
        }

        String sqlLoC = "";
        if (node.getDbOperation() != null && node.getDbOperation().getObjectType() == DbObjectTypeEnum.PROCEDURE_FUNCTION) {
            PlSqlObject plSqlObject = plSqlExplained.findByName(node.getDbOperation().getName());
            if (plSqlObject != null) {
                sqlLoC = String.format("\\n[LoC: %d, CRUD: %d]", plSqlObject.getLineOfCode(), plSqlObject.getCrudStatements());
            }
        }

        List entities = getEntityOperations.apply(node);
        if (entities.isEmpty()) {
            return sqlLoC + super.getSuffix(node);
        }

        String entityDesc = entities.stream().collect(Collectors.joining("\\n"));
        if (entityDesc != null && entityDesc.length() > 0) {
            entityDesc = "\\n" + entityDesc + "\\n";
        }

        return sqlLoC + entityDesc + super.getSuffix(node);
    }

    @Override
    protected String getNodeSelfExceptions(CallNode node, int level) {
        return "";
    }

    @Override
    protected String getNodeIsolatedExceptions(CallNode node, int level) {
        return "";
    }

    public void setGetEntityOperations(Function> getEntityOperations) {
        this.getEntityOperations = getEntityOperations;
    }

    public void setPlSqlExplained(PlSqlExplained plSqlExplained) {
        this.plSqlExplained = plSqlExplained;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy