diff --git a/Modules/RDF/CMakeLists.txt b/Modules/RDF/CMakeLists.txt index 56363dc4b6..572f6c337c 100644 --- a/Modules/RDF/CMakeLists.txt +++ b/Modules/RDF/CMakeLists.txt @@ -1,6 +1,9 @@ mitk_create_module(PACKAGE_DEPENDS Redland WARNINGS_AS_ERRORS ) add_subdirectory(Testing) +if(MSVC AND TARGET ${MODULE_TARGET}) + set_property(TARGET ${MODULE_TARGET} APPEND_STRING PROPERTY COMPILE_FLAGS " /wd4251") +endif() diff --git a/Modules/RDF/files.cmake b/Modules/RDF/files.cmake index 4fd8b64962..e58ca81787 100644 --- a/Modules/RDF/files.cmake +++ b/Modules/RDF/files.cmake @@ -1,3 +1,13 @@ set(CPP_FILES mitkRdfNode.cpp + mitkRdfUri.cpp + mitkRdfTriple.cpp + mitkRdfStore.cpp +) + +SET(H_FILES + mitkRdfNode.h + mitkRdfUri.h + mitkRdfTriple.h + mitkRdfStore.h ) diff --git a/Modules/RDF/mitkRdfNode.cpp b/Modules/RDF/mitkRdfNode.cpp index 73563bcbe9..f7f11fd20a 100644 --- a/Modules/RDF/mitkRdfNode.cpp +++ b/Modules/RDF/mitkRdfNode.cpp @@ -1,68 +1,115 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkRdfNode.h" +#include "mitkRdfUri.h" #include #include -#include #include #include namespace mitk { - -bool RdfNode::dummy() -{ - librdf_world* world; - librdf_storage *storage; - librdf_model* model; - librdf_statement* statement; - raptor_world *raptor_world_ptr; - raptor_iostream* iostr; - - world=librdf_new_world(); - librdf_world_open(world); - raptor_world_ptr = librdf_world_get_raptor(world); - - model=librdf_new_model(world, storage=librdf_new_storage(world, "hashes", NULL, "hash-type='memory'"), NULL); - - librdf_model_add_statement(model, - statement=librdf_new_statement_from_nodes(world, librdf_new_node_from_uri_string(world, (const unsigned char*)"http://www.dajobe.org/"), - librdf_new_node_from_uri_string(world, (const unsigned char*)"http://purl.org/dc/elements/1.1/creator"), - librdf_new_node_from_literal(world, (const unsigned char*)"Dave Beckett", NULL, 0) - ) - ); - - librdf_free_statement(statement); - - iostr = raptor_new_iostream_to_file_handle(raptor_world_ptr, stdout); - librdf_model_write(model, iostr); - raptor_free_iostream(iostr); - - librdf_free_model(model); - librdf_free_storage(storage); - - librdf_free_world(world); + RdfNode::RdfNode() + : type(Nothing), value(), datatype("") + { + } + + RdfNode::RdfNode(RdfUri uri) + : type(URI), value(uri.ToString()), datatype("") + { + } + + RdfNode::RdfNode(std::string text) + : type(Literal), value(text), datatype(RdfUri("")) + { + } + + RdfNode::RdfNode(std::string text, RdfUri dataType) + : type(Literal), value(text), datatype(dataType) + { + } + + RdfNode::~RdfNode() + { + } + + bool RdfNode::dummy() + { + librdf_world* world; + librdf_storage *storage; + librdf_model* model; + librdf_statement* statement; + raptor_world *raptor_world_ptr; + raptor_iostream* iostr; + + world=librdf_new_world(); + librdf_world_open(world); + raptor_world_ptr = librdf_world_get_raptor(world); + + model=librdf_new_model(world, storage=librdf_new_storage(world, "hashes", NULL, "hash-type='memory'"), NULL); + + librdf_model_add_statement(model, + statement=librdf_new_statement_from_nodes(world, librdf_new_node_from_uri_string(world, (const unsigned char*)"http://www.dajobe.org/"), + librdf_new_node_from_uri_string(world, (const unsigned char*)"http://purl.org/dc/elements/1.1/creator"), + librdf_new_node_from_literal(world, (const unsigned char*)"Dave Beckett", NULL, 0) + ) + ); + + librdf_free_statement(statement); + + iostr = raptor_new_iostream_to_file_handle(raptor_world_ptr, stdout); + librdf_model_write(model, iostr); + raptor_free_iostream(iostr); + + librdf_free_model(model); + librdf_free_storage(storage); + + librdf_free_world(world); #ifdef LIBRDF_MEMORY_DEBUG - librdf_memory_report(stderr); + librdf_memory_report(stderr); #endif - return true; -} - + return true; + } + + // Define outstream of a Node + std::ostream & operator<<(std::ostream &out, const mitk::RdfNode &n) + { + switch (n.type) { + case mitk::RdfNode::Nothing: + out << "[]"; + break; + case mitk::RdfNode::URI: + if (n.value == "") { + out << "[empty-uri]"; + } else { + out << "<" << n.value << ">"; + } + break; + case mitk::RdfNode::Literal: + out << "\"" << n.value << "\""; + if (n.datatype != mitk::RdfUri()) out << "^^" << n.datatype; + break; + case mitk::RdfNode::Blank: + out << "[blank " << n.value << "]"; + break; + } + return out; + } } diff --git a/Modules/RDF/mitkRdfNode.h b/Modules/RDF/mitkRdfNode.h index 83d8d99678..611777d2bb 100644 --- a/Modules/RDF/mitkRdfNode.h +++ b/Modules/RDF/mitkRdfNode.h @@ -1,39 +1,59 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ - #ifndef MITKRDFNODE_H #define MITKRDFNODE_H #include +#include "MitkRdfUri.h" + +#include +#include + namespace mitk { + /** + * \ingroup MitkRDFModule + */ + class MitkRDF_EXPORT RdfNode + { + public: + + enum Type { Nothing, URI, Literal, Blank}; + + // Construct a empty Node + RdfNode(); + + RdfNode(RdfUri uri); + + RdfNode(std::string text); -/** - * \ingroup MitkRDFModule - */ -class MitkRDF_EXPORT RdfNode -{ + RdfNode(std::string text, RdfUri dataType); -public: + virtual ~RdfNode(); - bool dummy(); + Type type; + RdfUri datatype; + std::string value; -}; + // dummy method for dummy test + bool dummy(); + }; + MitkRDF_EXPORT std::ostream & operator<<(std::ostream &out, const mitk::RdfNode &n); } #endif diff --git a/Modules/RDF/mitkRdfStore.cpp b/Modules/RDF/mitkRdfStore.cpp new file mode 100644 index 0000000000..a4d4f73b09 --- /dev/null +++ b/Modules/RDF/mitkRdfStore.cpp @@ -0,0 +1,316 @@ +/*=================================================================== + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. + +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. + +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ + +#include "mitkRdfStore.h" +#include "mitkRdfUri.h" +#include "mitkRdfTriple.h" +#include "mitkRdfNode.h" + +#include + +namespace mitk { + +class RdfStorePrivate { + +public: + RdfStorePrivate(); + ~RdfStorePrivate(); +}; + +RdfStore::RdfStore() + : m_BaseUri(0), m_World(0), m_Storage(0), m_Model(0) +{ + // SetUp base prefixes + m_Prefixes["rdf"] = RdfUri("http://www.w3.org/1999/02/22-rdf-syntax-ns#"); + m_Prefixes["rdfs"] = RdfUri("http://www.w3.org/2000/01/rdf-schema#"); + m_Prefixes["xsd"] = RdfUri("http://www.w3.org/2001/XMLSchema#"); + m_Prefixes["owl"] = RdfUri("http://www.w3.org/2002/07/owl#"); + + // SetUp new store + CleanUp(); +} + +RdfStore::~RdfStore() +{ + if(m_Model) + librdf_free_model(m_Model); + if(m_Storage) + librdf_free_storage(m_Storage); + if(m_World) + librdf_free_world(m_World); +} + +void RdfStore::SetBaseUri(RdfUri uri) +{ + m_BaseUri = uri; + m_Prefixes[""] = m_BaseUri; +} + +RdfUri RdfStore::GetBaseUri() +{ + return m_BaseUri; +} + +void RdfStore::AddPrefix(std::string prefix, RdfUri uri) +{ + m_Prefixes[prefix] = uri; +} + +void RdfStore::CleanUp() +{ + // CleanUp old Store if there is one + if(m_Model) + librdf_free_model(m_Model); + if(m_Storage) + librdf_free_storage(m_Storage); + if(m_World) + librdf_free_world(m_World); + + // SetUp new Store + m_World = librdf_new_world(); + librdf_world_open(m_World); + m_Storage = librdf_new_storage(m_World, "memory", 0, 0); + m_Model = librdf_new_model(m_World, m_Storage, 0); +} + +bool RdfStore::Add(RdfTriple triple) +{ + librdf_statement* statement = RdfTripleToStatement(triple); + + if (CheckComplete(statement)) + { + librdf_free_statement(statement); + return false; + } + + // Store already contains statement + if (Contains(triple)) return false; + + if (librdf_model_add_statement(m_Model, statement) != 0) { + librdf_free_statement(statement); + return false; + } + else + { + librdf_free_statement(statement); + return true; + } + return true; +} + +bool RdfStore::Remove(RdfTriple triple) +{ + librdf_statement* statement = RdfTripleToStatement(triple); + + if (CheckComplete(statement)) + { + librdf_free_statement(statement); + return false; + } + + // Store does not contain statement + if (!Contains(triple)) return false; + + if (librdf_model_remove_statement(m_Model, statement) != 0) { + librdf_free_statement(statement); + return false; + } + else + { + librdf_free_statement(statement); + return true; + } + return false; +} + +bool RdfStore::Contains(RdfTriple triple) +{ + librdf_statement* statement = RdfTripleToStatement(triple); + + // if 0 there is no triple + if (librdf_model_contains_statement(m_Model, statement) == 0) { + librdf_free_statement(statement); + return false; + } + else + { + librdf_free_statement(statement); + return true; + } + return false; +} + +void RdfStore::Save(std::string filename) +{ + SaveAs(filename, "turtle"); +} + +void RdfStore::SaveAs(std::string filename, std::string format) +{ + librdf_uri* baseUri = RdfUriToLibRdfUri(m_BaseUri); + librdf_serializer* s = librdf_new_serializer(m_World, format.c_str(), 0, 0); + + for (PrefixMap::const_iterator i = m_Prefixes.begin(); i != m_Prefixes.end(); ++i) + { + librdf_serializer_set_namespace(s, RdfUriToLibRdfUri(i->second), i->first.c_str()); + } + // May this is not relevant + librdf_serializer_set_namespace(s, RdfUriToLibRdfUri(m_BaseUri), ""); + + FILE* f = fopen(filename.c_str(), "w+"); + + librdf_serializer_serialize_model_to_file_handle(s, f, baseUri, m_Model); + + librdf_free_serializer(s); + librdf_free_uri(baseUri); +} + +void RdfStore::Import(std::string url, std::string format) +{ + std::string baseUri = m_BaseUri.ToString(); + + if (baseUri.empty()) + { + baseUri = url; + } + + // Redland uses relative paths like file:readme.txt + if (false) + { + /* TODO */ + } +} + +RdfStore* RdfStore::Load(std::string baseUri, std::string format) +{ + RdfStore* store = new RdfStore(); + store->SetBaseUri(RdfUri(baseUri)); + store->Import(baseUri, format); + return store; +} + +/***************************************************************************** + ********************************** Private ********************************** + *****************************************************************************/ + +bool RdfStore::CheckComplete(librdf_statement* statement) +{ + if (librdf_statement_is_complete(statement) != 0) return true; + else return false; +} + +librdf_statement* RdfStore::RdfTripleToStatement(RdfTriple triple) +{ + librdf_node* subject = RdfNodeToLibRdfNode(triple.GetSubject()); + librdf_node* predicate = RdfNodeToLibRdfNode(triple.GetPredicate()); + librdf_node* object = RdfNodeToLibRdfNode(triple.GetObject()); + + librdf_statement* statement = librdf_new_statement_from_nodes(m_World, subject, predicate, object); + if(!statement) return NULL; + return statement; +} + +librdf_node* RdfStore::RdfNodeToLibRdfNode(RdfNode node) +{ + librdf_node* newNode = NULL; + + switch (node.type) + { + case RdfNode::Nothing: + break; + case RdfNode::Blank: + newNode = librdf_new_node_from_blank_identifier(m_World, (const unsigned char*) node.value.c_str()); + break; + case RdfNode::Literal: + { + if (node.datatype != RdfUri()) + { + librdf_uri* typeUri = RdfUriToLibRdfUri(node.datatype); + newNode = librdf_new_node_from_typed_literal(m_World, (const unsigned char*) node.value.c_str(), 0, typeUri); + } + else + { + newNode = librdf_new_node_from_literal(m_World, (const unsigned char*) node.value.c_str(), 0, 0); + } + } + break; + case RdfNode::URI: + newNode = librdf_new_node_from_uri( m_World, librdf_new_uri(m_World, (const unsigned char*) node.value.c_str()) ); + break; + default: + break; + } + return newNode; +} + +librdf_uri* RdfStore::RdfUriToLibRdfUri(RdfUri uri) +{ + librdf_uri* libUri = librdf_new_uri(m_World, (const unsigned char*) uri.ToString().c_str()); + if (!libUri) return NULL; + return libUri; +} + +RdfTriple RdfStore::StatementToRdfTriple(librdf_statement* statement) +{ + librdf_node *subject = librdf_statement_get_subject(statement); + librdf_node *predicate = librdf_statement_get_predicate(statement); + librdf_node *object = librdf_statement_get_object(statement); + + RdfTriple triple(LibRdfNodeToRdfNode(subject), + LibRdfNodeToRdfNode(predicate), + LibRdfNodeToRdfNode(object)); + + return triple; +} + +RdfNode RdfStore::LibRdfNodeToRdfNode(librdf_node* node) +{ + RdfNode mitkNode = NULL; + + if (!node) return mitkNode; + + if (librdf_node_is_resource(node)) + { + mitkNode.type = RdfNode::URI; + librdf_uri *uri = librdf_node_get_uri(node); + mitkNode.value = LibRdfUriToRdfUri(uri).ToString(); + } + else if (librdf_node_is_literal(node)) + { + mitkNode.type = RdfNode::Literal; + std::string value = (const char*) librdf_node_get_literal_value(node); + if (!value.empty()) mitkNode.value = value; + librdf_uri* typeUri = librdf_node_get_literal_value_datatype_uri(node); + if (typeUri) mitkNode.datatype = LibRdfUriToRdfUri(typeUri); + } + else if (librdf_node_is_blank(node)) + { + mitkNode.type = RdfNode::Blank; + std::string str = (const char*) librdf_node_get_blank_identifier(node); + if (!str.empty()) mitkNode.value = str; + } + return mitkNode; +} + +RdfUri RdfStore::LibRdfUriToRdfUri(librdf_uri* uri) +{ + std::string str = (const char*) librdf_uri_as_string(uri); + if (!str.empty()) return RdfUri(str); + + return RdfUri(); +} + +} // end of namespace mitk diff --git a/Modules/RDF/mitkRdfStore.h b/Modules/RDF/mitkRdfStore.h new file mode 100644 index 0000000000..b6c355d7e4 --- /dev/null +++ b/Modules/RDF/mitkRdfStore.h @@ -0,0 +1,79 @@ +/*=================================================================== + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. + +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. + +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ + +#ifndef MITKRDFSTORE_H +#define MITKRDFSTORE_H + +#include +#include + +#include + +#include "mitkRdfUri.h" + +namespace mitk { + +class RdfTriple; +class RdfNode; + +class MitkRDF_EXPORT RdfStore +{ +public: + RdfStore(); + ~RdfStore(); + + void SetBaseUri(RdfUri uri); + RdfUri GetBaseUri(); + + void AddPrefix(std::string prefix, RdfUri uri); + void CleanUp(); + + bool Add(RdfTriple triple); + bool Remove(RdfTriple triple); + + bool Contains(RdfTriple triple); + + void Save(std::string filename); + void SaveAs(std::string filename, std::string format); + + void Import(std::string url, std::string format); + + static RdfStore* Load(std::string baseUri, std::string format=""); + +private: + RdfUri m_BaseUri; + + typedef std::map PrefixMap; + PrefixMap m_Prefixes; + + librdf_model* m_Model; + librdf_storage* m_Storage; + librdf_world* m_World; + + librdf_statement* RdfTripleToStatement(RdfTriple triple); + librdf_node* RdfNodeToLibRdfNode(RdfNode node); + librdf_uri* RdfUriToLibRdfUri(RdfUri uri); + + RdfTriple StatementToRdfTriple(librdf_statement* statement); + RdfNode LibRdfNodeToRdfNode(librdf_node* node); + RdfUri LibRdfUriToRdfUri(librdf_uri* uri); + + bool CheckComplete(librdf_statement* statement); +}; + +} + +#endif // MITKRDFSTORE_H diff --git a/Modules/RDF/mitkRdfTriple.cpp b/Modules/RDF/mitkRdfTriple.cpp new file mode 100644 index 0000000000..e3bd0f49c6 --- /dev/null +++ b/Modules/RDF/mitkRdfTriple.cpp @@ -0,0 +1,55 @@ +/*=================================================================== + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. + +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. + +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ + +#include "mitkRdfTriple.h" + +namespace mitk { + +RdfTriple::RdfTriple() +{ +} + +RdfTriple::RdfTriple(RdfNode x, RdfNode y, RdfNode z) + : subject(x), predicate(y), object(z) +{ +} + +RdfTriple::~RdfTriple() +{ +} + +RdfNode RdfTriple::GetSubject() const +{ + return subject; +} + +RdfNode RdfTriple::GetPredicate() const +{ + return predicate; +} + +RdfNode RdfTriple::GetObject() const +{ + return object; +} + +// Define outstream of a Triple +std::ostream & operator<<(std::ostream &out, const RdfTriple &t) +{ + return out << "( " << t.GetSubject() << " " << t.GetPredicate() << " " << t.GetObject() << " )"; +} + +} // end of namespace mitk diff --git a/Modules/RDF/mitkRdfNode.h b/Modules/RDF/mitkRdfTriple.h similarity index 51% copy from Modules/RDF/mitkRdfNode.h copy to Modules/RDF/mitkRdfTriple.h index 83d8d99678..cef0735006 100644 --- a/Modules/RDF/mitkRdfNode.h +++ b/Modules/RDF/mitkRdfTriple.h @@ -1,39 +1,52 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ - -#ifndef MITKRDFNODE_H -#define MITKRDFNODE_H +#ifndef MITKRDFTRIPLE_H +#define MITKRDFTRIPLE_H #include +#include "mitkRdfNode.h" + namespace mitk { -/** - * \ingroup MitkRDFModule - */ -class MitkRDF_EXPORT RdfNode +class MitkRDF_EXPORT RdfTriple { - public: + // Construct a empty Triple + RdfTriple(); + + // Construct a triple with three nodes + RdfTriple(RdfNode x, RdfNode y, RdfNode z); - bool dummy(); + virtual ~RdfTriple(); + + RdfNode GetSubject() const; + RdfNode GetPredicate() const; + RdfNode GetObject() const; + +private: + RdfNode subject; + RdfNode predicate; + RdfNode object; }; +MitkRDF_EXPORT std::ostream & operator<<(std::ostream &out, const RdfTriple &t); + } -#endif +#endif // MITKRDFTRIPLE_H diff --git a/Modules/RDF/mitkRdfNode.h b/Modules/RDF/mitkRdfUri.cpp similarity index 55% copy from Modules/RDF/mitkRdfNode.h copy to Modules/RDF/mitkRdfUri.cpp index 83d8d99678..1fff733855 100644 --- a/Modules/RDF/mitkRdfNode.h +++ b/Modules/RDF/mitkRdfUri.cpp @@ -1,39 +1,53 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ +#include "mitkRdfUri.h" -#ifndef MITKRDFNODE_H -#define MITKRDFNODE_H - -#include +#include namespace mitk { -/** - * \ingroup MitkRDFModule - */ -class MitkRDF_EXPORT RdfNode +RdfUri::RdfUri() + : m_Uri("") +{ +} + +RdfUri::RdfUri(std::string uri) + : m_Uri(uri) { +} -public: +RdfUri::~RdfUri() +{ +} - bool dummy(); +std::string RdfUri::ToString() +{ + return m_Uri; +} -}; +bool RdfUri::operator==(const RdfUri &u) const +{ + if (this->m_Uri.compare(u.m_Uri) != 0) return false; + return true; +} +bool RdfUri::operator!=(const RdfUri &u) const +{ + return !operator==(u); } -#endif +} // end of namespace mitk diff --git a/Modules/RDF/mitkRdfNode.h b/Modules/RDF/mitkRdfUri.h similarity index 64% copy from Modules/RDF/mitkRdfNode.h copy to Modules/RDF/mitkRdfUri.h index 83d8d99678..8c1c62d514 100644 --- a/Modules/RDF/mitkRdfNode.h +++ b/Modules/RDF/mitkRdfUri.h @@ -1,39 +1,45 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ - -#ifndef MITKRDFNODE_H -#define MITKRDFNODE_H +#ifndef MITKRDFURI_H +#define MITKRDFURI_H #include +#include + namespace mitk { -/** - * \ingroup MitkRDFModule - */ -class MitkRDF_EXPORT RdfNode +class MitkRDF_EXPORT RdfUri { - public: + RdfUri(); + RdfUri(std::string uri); + + virtual ~RdfUri(); + + std::string ToString(); - bool dummy(); + bool operator==(const RdfUri &u) const; + bool operator!=(const RdfUri &u) const; +private: + std::string m_Uri; }; } -#endif +#endif // MITKRDFURI_H diff --git a/Plugins/PluginList.cmake b/Plugins/PluginList.cmake index 3bf25ed2aa..d87c4fbac7 100644 --- a/Plugins/PluginList.cmake +++ b/Plugins/PluginList.cmake @@ -1,49 +1,50 @@ # Plug-ins must be ordered according to their dependencies set(MITK_EXT_PLUGINS org.mitk.core.services:ON org.mitk.gui.common:ON org.mitk.planarfigure:ON org.mitk.core.ext:OFF org.mitk.core.jobs:OFF org.mitk.diffusionimaging:OFF org.mitk.simulation:OFF org.mitk.gui.qt.application:ON org.mitk.gui.qt.coreapplication:OFF org.mitk.gui.qt.ext:OFF org.mitk.gui.qt.extapplication:OFF org.mitk.gui.qt.common:ON org.mitk.gui.qt.stdmultiwidgeteditor:ON org.mitk.gui.qt.common.legacy:OFF org.mitk.gui.qt.cmdlinemodules:OFF org.mitk.gui.qt.diffusionimagingapp:OFF org.mitk.gui.qt.datamanager:ON org.mitk.gui.qt.datamanagerlight:OFF org.mitk.gui.qt.properties:ON org.mitk.gui.qt.basicimageprocessing:OFF org.mitk.gui.qt.dicom:OFF org.mitk.gui.qt.diffusionimaging:OFF org.mitk.gui.qt.dtiatlasapp:OFF org.mitk.gui.qt.igtexamples:OFF org.mitk.gui.qt.igttracking:OFF org.mitk.gui.qt.imagecropper:OFF org.mitk.gui.qt.imagenavigator:ON org.mitk.gui.qt.viewnavigator:OFF org.mitk.gui.qt.materialeditor:OFF org.mitk.gui.qt.measurementtoolbox:OFF org.mitk.gui.qt.moviemaker:OFF org.mitk.gui.qt.pointsetinteraction:OFF org.mitk.gui.qt.python:OFF org.mitk.gui.qt.registration:OFF org.mitk.gui.qt.remeshing:OFF org.mitk.gui.qt.segmentation:OFF org.mitk.gui.qt.simulation:OFF org.mitk.gui.qt.toftutorial:OFF org.mitk.gui.qt.tofutil:OFF org.mitk.gui.qt.ugvisualization:OFF org.mitk.gui.qt.ultrasound:OFF org.mitk.gui.qt.volumevisualization:OFF org.mitk.gui.qt.eventrecorder:OFF org.mitk.gui.qt.xnat:OFF + org.mitk.gui.qt.rdftriplestore:OFF ) diff --git a/Plugins/org.mitk.gui.qt.rdftriplestore/CMakeLists.txt b/Plugins/org.mitk.gui.qt.rdftriplestore/CMakeLists.txt new file mode 100644 index 0000000000..06a60fb191 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.rdftriplestore/CMakeLists.txt @@ -0,0 +1,7 @@ +project(org_mitk_gui_qt_rdftriplestore) + +MACRO_CREATE_MITK_CTK_PLUGIN( + MODULE_DEPENDS MitkRDF + EXPORT_DIRECTIVE RDFTRIPLESTORE_EXPORT + EXPORTED_INCLUDE_SUFFIXES src +) diff --git a/Plugins/org.mitk.gui.qt.rdftriplestore/documentation/UserManual/Manual.dox b/Plugins/org.mitk.gui.qt.rdftriplestore/documentation/UserManual/Manual.dox new file mode 100644 index 0000000000..02011bc12c --- /dev/null +++ b/Plugins/org.mitk.gui.qt.rdftriplestore/documentation/UserManual/Manual.dox @@ -0,0 +1,18 @@ +/** +\bundlemainpage{org.mitk.gui.qt.rdftriplestore} Rdftriplestore + +imageMacro{"icon.xpm","Icon of Rdftriplestore",2.00} + +Available sections: + - \ref org.mitk.gui.qt.rdftriplestoreOverview + +\section org.mitk.gui.qt.rdftriplestoreOverview +Describe the features of your awesome plugin here +
    +
  • Increases productivity +
  • Creates beautiful images +
  • Generates PhD thesis +
  • Brings world peace +
+ +*/ diff --git a/Plugins/org.mitk.gui.qt.rdftriplestore/documentation/UserManual/icon.xpm b/Plugins/org.mitk.gui.qt.rdftriplestore/documentation/UserManual/icon.xpm new file mode 100644 index 0000000000..83e48be4d8 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.rdftriplestore/documentation/UserManual/icon.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * icon_xpm[] = { +"16 16 2 1", +" c #FF0000", +". c #000000", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" "}; diff --git a/Plugins/org.mitk.gui.qt.rdftriplestore/documentation/doxygen/modules.dox b/Plugins/org.mitk.gui.qt.rdftriplestore/documentation/doxygen/modules.dox new file mode 100644 index 0000000000..0f888348cf --- /dev/null +++ b/Plugins/org.mitk.gui.qt.rdftriplestore/documentation/doxygen/modules.dox @@ -0,0 +1,16 @@ +/** + \defgroup org_mitk_gui_qt_rdftriplestore org.mitk.gui.qt.rdftriplestore + \ingroup MITKPlugins + + \brief Describe your plugin here. + +*/ + +/** + \defgroup org_mitk_gui_qt_rdftriplestore_internal Internal + \ingroup org_mitk_gui_qt_rdftriplestore + + \brief This subcategory includes the internal classes of the org.mitk.gui.qt.rdftriplestore plugin. Other + plugins must not rely on these classes. They contain implementation details and their interface + may change at any time. We mean it. +*/ diff --git a/Plugins/org.mitk.gui.qt.rdftriplestore/files.cmake b/Plugins/org.mitk.gui.qt.rdftriplestore/files.cmake new file mode 100644 index 0000000000..594ce5220c --- /dev/null +++ b/Plugins/org.mitk.gui.qt.rdftriplestore/files.cmake @@ -0,0 +1,42 @@ +set(SRC_CPP_FILES + +) + +set(INTERNAL_CPP_FILES + org_mitk_gui_qt_rdftriplestore_Activator.cpp + QmitkRdfTriplestoreView.cpp +) + +set(UI_FILES + src/internal/QmitkRdfTriplestoreViewControls.ui +) + +set(MOC_H_FILES + src/internal/org_mitk_gui_qt_rdftriplestore_Activator.h + src/internal/QmitkRdfTriplestoreView.h +) + +# list of resource files which can be used by the plug-in +# system without loading the plug-ins shared library, +# for example the icon used in the menu and tabs for the +# plug-in views in the workbench +set(CACHED_RESOURCE_FILES + resources/icon.xpm + plugin.xml +) + +# list of Qt .qrc files which contain additional resources +# specific to this plugin +set(QRC_FILES + +) + +set(CPP_FILES ) + +foreach(file ${SRC_CPP_FILES}) + set(CPP_FILES ${CPP_FILES} src/${file}) +endforeach(file ${SRC_CPP_FILES}) + +foreach(file ${INTERNAL_CPP_FILES}) + set(CPP_FILES ${CPP_FILES} src/internal/${file}) +endforeach(file ${INTERNAL_CPP_FILES}) diff --git a/Plugins/org.mitk.gui.qt.rdftriplestore/manifest_headers.cmake b/Plugins/org.mitk.gui.qt.rdftriplestore/manifest_headers.cmake new file mode 100644 index 0000000000..5c617a9ef9 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.rdftriplestore/manifest_headers.cmake @@ -0,0 +1,5 @@ +set(Plugin-Name "Rdftriplestore") +set(Plugin-Version "0.1") +set(Plugin-Vendor "DKFZ, Medical and Biological Informatics") +set(Plugin-ContactAddress "") +set(Require-Plugin org.mitk.gui.qt.common) diff --git a/Plugins/org.mitk.gui.qt.rdftriplestore/plugin.xml b/Plugins/org.mitk.gui.qt.rdftriplestore/plugin.xml new file mode 100644 index 0000000000..a831c60e82 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.rdftriplestore/plugin.xml @@ -0,0 +1,11 @@ + + + + + + + + diff --git a/Plugins/org.mitk.gui.qt.rdftriplestore/resources/icon.xpm b/Plugins/org.mitk.gui.qt.rdftriplestore/resources/icon.xpm new file mode 100644 index 0000000000..83e48be4d8 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.rdftriplestore/resources/icon.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * icon_xpm[] = { +"16 16 2 1", +" c #FF0000", +". c #000000", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" "}; diff --git a/Plugins/org.mitk.gui.qt.rdftriplestore/src/internal/QmitkRdfTriplestoreView.cpp b/Plugins/org.mitk.gui.qt.rdftriplestore/src/internal/QmitkRdfTriplestoreView.cpp new file mode 100644 index 0000000000..251c3064ac --- /dev/null +++ b/Plugins/org.mitk.gui.qt.rdftriplestore/src/internal/QmitkRdfTriplestoreView.cpp @@ -0,0 +1,84 @@ +/*=================================================================== + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. + +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. + +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ + +// Blueberry +#include +#include + +// Qmitk +#include "QmitkRdfTriplestoreView.h" + +// Qt +#include + +// MitkRdf +#include +#include +#include +#include + +const std::string QmitkRdfTriplestoreView::VIEW_ID = "org.mitk.views.qmitkrdftriplestoreview"; + +void QmitkRdfTriplestoreView::SetFocus() +{ + m_Controls.buttonPerformImageProcessing->setFocus(); +} + +void QmitkRdfTriplestoreView::CreateQtPartControl( QWidget *parent ) +{ + // create GUI widgets from the Qt Designer's .ui file + m_Controls.setupUi( parent ); + connect( m_Controls.buttonPerformImageProcessing, SIGNAL(clicked()), this, SLOT(DoImageProcessing()) ); +} + +void QmitkRdfTriplestoreView::OnSelectionChanged( berry::IWorkbenchPart::Pointer /*source*/, + const QList& nodes ) +{ +} + +void QmitkRdfTriplestoreView::DoImageProcessing() +{ + typedef mitk::RdfStore Store; + typedef mitk::RdfTriple Triple; + typedef mitk::RdfNode Node; + typedef mitk::RdfUri Uri; + + // Create a new Store + Store store; + + // Create a new base URI for the store and set it into the store + std::string base = "http://www.mitk.org/Base"; + Uri baseUri(base); + + // Create some nodes + mitk::RdfNode project1(mitk::RdfUri("http://www.mitk.org/rdfOntology/resource.rdf#Project1")); + mitk::RdfNode subject1(mitk::RdfUri("http://www.mitk.org/rdfOntology/resource.rdf#Subject1")); + + // Create some predicate(/property) nodes + mitk::RdfNode hasA(mitk::RdfUri("http://www.mitk.org/rdfOntology/property.rdf#hasA")); + mitk::RdfNode name(mitk::RdfUri("http://www.mitk.org/rdfOntology/property.rdf#name")); + + // Create some triples + mitk::RdfTriple t1(project1, hasA, subject1); + mitk::RdfTriple t2(project1, name, (std::string) "MyProject"); + + // Add triples to store + store.Add(t1); + store.Add(t1); + + // Save the store in a local path + store.Save("C:/Users/knorr/Desktop/storeFromMitk.rdf"); +} diff --git a/Plugins/org.mitk.gui.qt.rdftriplestore/src/internal/QmitkRdfTriplestoreView.h b/Plugins/org.mitk.gui.qt.rdftriplestore/src/internal/QmitkRdfTriplestoreView.h new file mode 100644 index 0000000000..64b4895ff4 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.rdftriplestore/src/internal/QmitkRdfTriplestoreView.h @@ -0,0 +1,62 @@ +/*=================================================================== + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. + +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. + +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ + +#ifndef QmitkRdfTriplestoreView_h +#define QmitkRdfTriplestoreView_h + +#include + +#include + +#include "ui_QmitkRdfTriplestoreViewControls.h" + +/*! +\brief QmitkRdfTriplestoreView + +\warning This class is not yet documented. Use "git blame" and ask the author to provide basic documentation. + +\sa QmitkFunctionality +\ingroup ${plugin_target}_internal +*/ +class QmitkRdfTriplestoreView : public QmitkAbstractView +{ + // this is needed for all Qt objects that should have a Qt meta-object + // (everything that derives from QObject and wants to have signal/slots) + Q_OBJECT + +public: + + static const std::string VIEW_ID; + + virtual void CreateQtPartControl(QWidget *parent); + + protected slots: + + /// \brief Called when the user clicks the GUI button + void DoImageProcessing(); + +protected: + + virtual void SetFocus(); + + /// \brief called by QmitkFunctionality when DataManager's selection has changed + virtual void OnSelectionChanged( berry::IWorkbenchPart::Pointer source, + const QList& nodes ); + + Ui::QmitkRdfTriplestoreViewControls m_Controls; +}; + +#endif // QmitkRdfTriplestoreView_h diff --git a/Plugins/org.mitk.gui.qt.rdftriplestore/src/internal/QmitkRdfTriplestoreViewControls.ui b/Plugins/org.mitk.gui.qt.rdftriplestore/src/internal/QmitkRdfTriplestoreViewControls.ui new file mode 100644 index 0000000000..bd92fb02ba --- /dev/null +++ b/Plugins/org.mitk.gui.qt.rdftriplestore/src/internal/QmitkRdfTriplestoreViewControls.ui @@ -0,0 +1,64 @@ + + + QmitkRdfTriplestoreViewControls + + + + 0 + 0 + 222 + 161 + + + + + 0 + 0 + + + + QmitkTemplate + + + + + + QLabel { color: rgb(255, 0, 0) } + + + Please select an image! + + + + + + + Do image processing + + + Do Something + + + + + + + Qt::Vertical + + + QSizePolicy::Expanding + + + + 20 + 220 + + + + + + + + + + diff --git a/Modules/RDF/mitkRdfNode.h b/Plugins/org.mitk.gui.qt.rdftriplestore/src/internal/org_mitk_gui_qt_rdftriplestore_Activator.cpp similarity index 52% copy from Modules/RDF/mitkRdfNode.h copy to Plugins/org.mitk.gui.qt.rdftriplestore/src/internal/org_mitk_gui_qt_rdftriplestore_Activator.cpp index 83d8d99678..f344d2a0c0 100644 --- a/Modules/RDF/mitkRdfNode.h +++ b/Plugins/org.mitk.gui.qt.rdftriplestore/src/internal/org_mitk_gui_qt_rdftriplestore_Activator.cpp @@ -1,39 +1,35 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ +#include "org_mitk_gui_qt_rdftriplestore_Activator.h" -#ifndef MITKRDFNODE_H -#define MITKRDFNODE_H +#include -#include +#include "QmitkRdfTriplestoreView.h" namespace mitk { - -/** - * \ingroup MitkRDFModule - */ -class MitkRDF_EXPORT RdfNode -{ - -public: - - bool dummy(); - -}; - + void org_mitk_gui_qt_rdftriplestore_Activator::start(ctkPluginContext* context) + { + BERRY_REGISTER_EXTENSION_CLASS(QmitkRdfTriplestoreView, context) + } + + void org_mitk_gui_qt_rdftriplestore_Activator::stop(ctkPluginContext* context) + { + Q_UNUSED(context) + } } -#endif +Q_EXPORT_PLUGIN2(org_mitk_gui_qt_rdftriplestore, mitk::org_mitk_gui_qt_rdftriplestore_Activator) diff --git a/Modules/RDF/mitkRdfNode.h b/Plugins/org.mitk.gui.qt.rdftriplestore/src/internal/org_mitk_gui_qt_rdftriplestore_Activator.h similarity index 51% copy from Modules/RDF/mitkRdfNode.h copy to Plugins/org.mitk.gui.qt.rdftriplestore/src/internal/org_mitk_gui_qt_rdftriplestore_Activator.h index 83d8d99678..c25ff7eba4 100644 --- a/Modules/RDF/mitkRdfNode.h +++ b/Plugins/org.mitk.gui.qt.rdftriplestore/src/internal/org_mitk_gui_qt_rdftriplestore_Activator.h @@ -1,39 +1,36 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ +#ifndef org_mitk_gui_qt_rdftriplestore_Activator_h +#define org_mitk_gui_qt_rdftriplestore_Activator_h -#ifndef MITKRDFNODE_H -#define MITKRDFNODE_H - -#include +#include namespace mitk { + class org_mitk_gui_qt_rdftriplestore_Activator : + public QObject, public ctkPluginActivator + { + Q_OBJECT + Q_INTERFACES(ctkPluginActivator) -/** - * \ingroup MitkRDFModule - */ -class MitkRDF_EXPORT RdfNode -{ - -public: - - bool dummy(); - -}; + public: + void start(ctkPluginContext* context); + void stop(ctkPluginContext* context); + }; // org_mitk_gui_qt_rdftriplestore_Activator } -#endif +#endif // org_mitk_gui_qt_rdftriplestore_Activator_h