Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: link library for dot #903

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

npetzall
Copy link
Member

@npetzall npetzall commented Jun 6, 2022

Link library to remove createPath() from DotNode

private String createPath(boolean fromRoot) {
if (dotConfig.useRelativeLinks()) {
return (table.isRemote() ? "../../../" + new FileNameGenerator().generate(table.getContainer()) : "../..") + TABLES_PATH;
}
if (fromRoot) {
return (table.isRemote() ? ("../" + new FileNameGenerator().generate(table.getContainer()) + TABLES_PATH) : "tables/");
}
return (table.isRemote() ? ("../../" + new FileNameGenerator().generate(table.getContainer()) + TABLES_PATH) : "");
}

But also remove isOneOfMultipleSchemas()

if (!table.isRemote() || dotConfig.isOneOfMultipleSchemas()) {
buf.append(" URL=\"" + path + urlEncodeLink(new FileNameGenerator().generate(tableName)) + ".html\"" + lineSeparator);
buf.append(" target=\"_top\"" + lineSeparator);
}

Enabling us to remove useRelativeLinks() from
Enabling us to remove isOneOfMultipleSchemas() from Config/DotConfig/HtmlConfig since it set in runtime and not config from cli. There are more places that needs changing.

RelativeToDiagramTableNodeLinkFactoryBuilder relativeToDiagramTableNodeLinkFactoryBuilder =
  new RelativeToDiagramTableNodeLinkFactoryBuilder(diagramFactory);
AddTableNodeLinkFactoryBuilder addTableNodeLinkFactoryBuilder =
  new AddTableNodeLinkFactoryBuilder(multiSchema);


MustacheSummaryDiagramFactory mustacheSummaryDiagramFactory =
  new MustacheSummaryDiagramFactory(
    new DotSummaryFormatter(
      dotConfig,
      addTableNodeLinkFactoryBuilder.withTableNodeLinkFactory(
        new WithTargetTopTableNodeLinkFactory(
          relativeToDiagramTableNodeLinkFactoryBuilder.withTableNodeLinkFactory(
            new FromBaseTableNodeLinkFactory()
          )
		)
      )
	),
    mustacheDiagramFactory,
    impliedConstraintsFinder,
    outputDir
  );

MustacheOrphanDiagramFactory mustacheOrphanDiagramFactory = 
  new MustacheOrphanDiagramFactory(
    dotConfig,
    addTableNodeLinkFactoryBuilder.withTableNodeLinkFactory(
      new WithTargetTopTableNodeLinkFactory(
        relativeToDiagramTableNodeLinkFactoryBuilder.withTableNodeLinkFactory(
          new FromBaseTableNodeLinkFactory()
        )
      )
    ),
    mustacheDiagramFactory,
    outputDir
  );

DotFormatter dotFormatter = 
  new DotFormatter(
    dotConfig, 
    addTableNodeLinkFactoryBuilder.withTableNodeLinkFactory(
      new WithTargetTopTableNodeLinkFactory(
        relativeToDiagramTableNodeLinkFactoryBuilder.withTableNodeLinkFactory(
          new RelativeTableNodeLinkFactory()
        )
      )
    )
  );

@npetzall npetzall marked this pull request as draft June 6, 2022 23:29

import org.schemaspy.model.Table;

public class AddTableNodeLinkFactory implements TableNodeLinkFactory{
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs a better name

@Override
public NodeLink nodeLink(Table table) {
if (table.isRemote()) {
return new RemoteFromBase(table, new HtmlWithEncodedName(table));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HtmlWithEncodedName should probably be it's own Factory


@Override
public String asString() {
return " URL=\"" +nodeLink.asString() + "\"" +
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

URL maybe a separate factory

@npetzall
Copy link
Member Author

npetzall commented Jun 6, 2022

Could be simplified by returning string instead of NodeLink.

@jesperolsson-se if you have the time could you help me with this.

@npetzall
Copy link
Member Author

npetzall commented Jun 6, 2022

Usage commit: npetzall@8167703
Unused removal: npetzall@45c5019
isOneOfMultipleSchemas removal: npetzall@314a7eb

Just to show some of the enabling.

@npetzall
Copy link
Member Author

npetzall commented Jun 7, 2022

If #900 is fruitful,

The awkward

RelativeToDiagramTableNodeLinkFactoryBuilder relativeToDiagramTableNodeLinkFactoryBuilder =
  new RelativeToDiagramTableNodeLinkFactoryBuilder(diagramFactory);

Can be removed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant