Commit b116727f authored by Jonas Smedegaard's avatar Jonas Smedegaard

Fix create deterministic output.

parent 04bfaeeb
......@@ -198,7 +198,7 @@ stereotypes();
replace_inlines();
collect_predicate_arrows();
for my $s ($model->subjects(undef,undef)) {
for my $s ( sort { RDF::Trine::Node::compare( $a, $b ) } $model->subjects(undef,undef) ) {
my $s1 = puml_node($s);
my $noReify = print_types ($s, $s1); # types come first
print_relations ($s, $s1, $noReify);
......@@ -210,7 +210,7 @@ myprint ("\@enduml\n");
sub print_types {
my ($s, $s1) = @_;
my @types = map puml_node2($_), $model->objects ($s, U("rdf:type"));
my @types = sort map puml_node2($_), $model->objects ($s, U("rdf:type"));
my $noReify = grep m{puml:NoReify}, @types;
my $types = join ", ", grep !m{puml:NoReify}, @types;
myprint (qq{$s1 : a $types\n}) if $types;
......@@ -219,11 +219,12 @@ sub print_types {
sub print_relations {
my ($s, $s1, $noReify) = @_;
for my $o ($model->objects ($s, undef, undef, type=>'resource'),
for my $o (sort { RDF::Trine::Node::compare( $a, $b ) }
$model->objects ($s, undef, undef, type=>'resource'),
$model->objects ($s, undef, undef, type=>'blank')) {
# collect all relations between the two nodes.
# TODO: also collect inverse relations? Then be careful for reifications!
my @predicates = grep !m{rdf:type}, map puml_predicate($_), $model->predicates ($s, $o);
my @predicates = grep !m{rdf:type}, sort map puml_predicate($_), $model->predicates ($s, $o);
# TODO: remove actually reified predicates (see reification()), not potentially reifiable ($NOREL)
@predicates = grep !m{$NOREL}o, @predicates if !$noReify;
next unless @predicates;
......
  • This is a good fix, but you need to examine the PNG outputs. Order in the PUML may affect the layout, and it might be for the worse. I think that Trine returns them in the same order as in the input Turtle, not in random order?

    BTW, are you going to add a section CHANGES to the README (before sec TODO)? I have a puny ChangeLog file but don't like the way it works.

    Edited by Vladimir Alexiev
  • Quoting Vladimir Alexiev (2018-12-07 11:18:44)

    This is a good fix, but you need to examine the PNG outputs.

    s/you/we/

    Great that you are sceptical about my changes. Please check this too.

    Order in the PUML may

    Seems you didn't finish above sentence...

    BTW, are you going to add a section CHANGES to the README (before sec TODO)? I have a puny ChangeLog file but don't like the way it works.

    That is unrelated to this commit. Please let's stick to the topic.

    signature.asc

Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment