1. Konstantin Baierer
  2. p5-moosex-semantic

Commits

Konstantin Baierer  committed 1c2b5dd

Bug fix: ArrayRef[RDF::Trine::Node::Literal] wasn't recognized as such, now is, HACKY

  • Participants
  • Parent commits cca29df
  • Branches default

Comments (0)

Files changed (4)

File Changes

View file
  • Ignore whitespace
-0.004	2012-04-06
+0.005	2012-04-06
     * Missing dependencies (MXR::Parametrized, Sort::Naturally)
 0.004   2012-03-31
     * fixed some tests

File TODO

View file
  • Ignore whitespace
+Sun Aug 26 22:16:56 CEST 2012
+-----------------------------
+* Export should take Trine::Literals as Array Elements into account
+
 Mon Jun  4 01:10:53 CEST 2012
 -----------------------------
 * Interesting paper from ESWC2012 about object-oriented class instantiation

File lib/MooseX/Semantic/Util/TypeConstraintWalker.pm

View file
  • Ignore whitespace
             # warn Dumper $attr_name;
             # warn Dumper ref $attr_type;
             $attr_type = $attr_type->__type_constraint->parent;
-            # p $attr_type;
+#            p $attr_type;
         }
         # else {
         #     # p $attr_name;
                 # p $attr_type;
                 $callback_name = 'literal_in_array';
             }
+            elsif ( $attr_type->type_parameter =~ 'Literal' ) {
+                # warn Dumper ref $attr_type;
+                # p $attr_type;
+                $callback_name = 'literal_in_array';
+            }
             elsif ( $self->_find_parent_type( $attr_type->type_parameter, 'Object' ) 
             or      $self->_find_parent_type( $attr_type->type_parameter, 'ClassName' ) ) 
             {
             {
                 $callback_name = 'literal_in_array';
             }
+            else {
+                warn "Can't handle this ArrayRef: " . $attr_type;
+                warn Dumper ref $attr_type;
+            }
         }
         else {
             # warn Dumper $attr_type->has_parent;

File t/util/schema_import/dynamic_class.t

View file
  • Ignore whitespace
 # use Test::More tests=>5;
-use Test::More skip_all => 'TODO: re-test this with RDF::TrineX::RuleEngine::Jena';
+use Test::More 
+    # skip_all => 'TODO: re-test this with RDF::TrineX::RuleEngine::Jena'
+    ;
 use Test::Moose;
 use RDF::Trine::Namespace qw(rdf);
 use Data::Dumper;
 };
 my $importer = MooseX::Semantic::Util::SchemaImport->new;
 
-# {
-#     diag "without reasoning";
-#     $importer->initialize_classes_from_model(
-#         base_uri => $foaf,
-#         model_file => 't/data/ontologies/foaf.rdf',
-#         type_map => $type_map,
-#     );
-
-
-#     ok( $type_map->{ $foaf->Person }->meta, 'foaf:Person mapped to Moose' );
-#     ok( $type_map->{ $foaf->Document }->meta, 'foaf:Document mapped to Moose' );
-#     is( scalar $foaf_Person_cls->meta->get_attribute_list,
-#         16,
-#         '16 attributes for foaf:Person');
-#     is( scalar $foaf_Document_cls->meta->get_attribute_list,
-#         2,
-#         '2 attributes for foaf:Document');
-#     is( $foaf_Person_cls->meta->get_attribute('knows')->type_constraint->name,
-#         'ArrayRef[My::Test::Bla::Foo::Person]', 
-#         'foaf:knows is right for foaf:Person');
-# }
 {
-    diag "with reasoning";
-
-    my $parser = RDF::Trine::Parser->new('rdfxml');
-
-    my $model_ass = RDF::Trine::Model->temporary_model;
-    $parser->parse_file_into_model('http://example.org', 't/data/ontologies/foaf.rdf', $model_ass);
-    warn Dumper $model_ass->size;
-
-
-    my $inferred = qx{bash bin/reason.sh t/data/ontologies/foaf.rdf};
-    my $model_inf = RDF::Trine::Model->temporary_model;
-    $parser->parse_into_model('http://example.org', $inferred, $model_inf);
-    warn Dumper $model_inf->size;
-
+    diag "without reasoning";
     $importer->initialize_classes_from_model(
         base_uri => $foaf,
-        model => $model_inf,
+        model_file => 't/data/ontologies/foaf.rdf',
         type_map => $type_map,
     );
 
+
     ok( $type_map->{ $foaf->Person }->meta, 'foaf:Person mapped to Moose' );
     ok( $type_map->{ $foaf->Document }->meta, 'foaf:Document mapped to Moose' );
     is( scalar $foaf_Person_cls->meta->get_attribute_list,
     is( scalar $foaf_Document_cls->meta->get_attribute_list,
         2,
         '2 attributes for foaf:Document');
-    warn Dumper $foaf_Document_cls->meta->get_attribute_list;
     is( $foaf_Person_cls->meta->get_attribute('knows')->type_constraint->name,
         'ArrayRef[My::Test::Bla::Foo::Person]', 
         'foaf:knows is right for foaf:Person');
 }
+#{
+#    diag "with reasoning";
+#
+#    my $parser = RDF::Trine::Parser->new('rdfxml');
+#
+#    my $model_ass = RDF::Trine::Model->temporary_model;
+#    $parser->parse_file_into_model('http://example.org', 't/data/ontologies/foaf.rdf', $model_ass);
+#    warn Dumper $model_ass->size;
+#
+#
+#    my $inferred = qx{bash bin/reason.sh t/data/ontologies/foaf.rdf};
+#    my $model_inf = RDF::Trine::Model->temporary_model;
+#    $parser->parse_into_model('http://example.org', $inferred, $model_inf);
+#    warn Dumper $model_inf->size;
+#
+#    $importer->initialize_classes_from_model(
+#        base_uri => $foaf,
+#        model => $model_inf,
+#        type_map => $type_map,
+#    );
+#
+#    ok( $type_map->{ $foaf->Person }->meta, 'foaf:Person mapped to Moose' );
+#    ok( $type_map->{ $foaf->Document }->meta, 'foaf:Document mapped to Moose' );
+#    is( scalar $foaf_Person_cls->meta->get_attribute_list,
+#        16,
+#        '16 attributes for foaf:Person');
+#    is( scalar $foaf_Document_cls->meta->get_attribute_list,
+#        2,
+#        '2 attributes for foaf:Document');
+#    warn Dumper $foaf_Document_cls->meta->get_attribute_list;
+#    is( $foaf_Person_cls->meta->get_attribute('knows')->type_constraint->name,
+#        'ArrayRef[My::Test::Bla::Foo::Person]', 
+#        'foaf:knows is right for foaf:Person');
+#}