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

Link fixes #81

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions ome-xml/src/main/cpp/ome/xml/model/detail/OMEModelObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@

#include <ome/common/xml/String.h>

#include <ome/xml/model/Reference.h>
#include <ome/xml/model/detail/OMEModelObject.h>

namespace ome
Expand Down Expand Up @@ -104,9 +105,14 @@ namespace ome
}

bool
OMEModelObject::link (std::shared_ptr<Reference>& /* reference */,
std::shared_ptr<::ome::xml::model::OMEModelObject>& /* object */)
OMEModelObject::link (std::shared_ptr<Reference>& reference,
std::shared_ptr<::ome::xml::model::OMEModelObject>& object)
{
BOOST_LOG_SEV(logger, ome::logging::trivial::warning)
<< elementName()
<< " unable to handle reference of type "
<< reference->elementName()
<< " for " << object->elementName();
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,19 @@
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* @author callan
*
*/
public abstract class AbstractOMEModelObject implements OMEModelObject {

/** Logger for this class. */
protected static final Logger LOGGER =
LoggerFactory.getLogger(AbstractOMEModelObject.class);

/* (non-Javadoc)
* @see ome.xml.r201004.OMEModelObject#update(org.w3c.dom.Element, ome.xml.r201004.OMEModel)
*/
Expand Down Expand Up @@ -82,6 +89,8 @@ protected Element asXMLElement(Document document, Element element) {
*/
@Override
public boolean link(Reference reference, OMEModelObject o) {
LOGGER.debug("{} unable to handle reference of type {} for {}",
getClass(), reference.getClass(), o.getClass());
return false;
}

Expand Down
10 changes: 4 additions & 6 deletions xsd-fu/templates-cpp/OMEXMLMetadata.template
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,9 @@ OMEXMLMetadata::${getPropMethod(is_multi_path[o.name], parent, obj.name, prop)}(
{% choose %}\
{% when is_abstract(parent) and prop.isReference %}\
// ${prop.name} is abstract and is a reference
std::shared_ptr<${prop.instanceTypeNS}> ${prop.instanceVariableName}_reference(std::make_shared<${prop.instanceTypeNS}>());
${prop.instanceVariableName}_reference->setID(${prop.argumentName});
std::shared_ptr<ome::xml::model::Reference> ref(std::static_pointer_cast<ome::xml::model::reference>(std::make_shared<${prop.instanceTypeNS}>()));
ref->setID(${prop.argumentName});
std::shared_ptr<::${lang.omexml_model_package}::OMEModelObject> o_base(std::static_pointer_cast<::${lang.omexml_model_package}::OMEModelObject>(${safe_accessor([{'accessor':'root'}]+accessor(obj.name, parent, prop, func=accessor_string_complex)[:-1], setPropMethod(is_multi_path[o.name], parent, obj.name, prop))}));
std::shared_ptr<::${lang.omexml_model_package}::Reference> ref(std::static_pointer_cast<::${lang.omexml_model_package}::Reference>(${prop.instanceVariableName}_reference));

model->addReference(o_base, ref);
// ${parent} is abstract
Expand Down Expand Up @@ -269,10 +268,9 @@ OMEXMLMetadata::${getPropMethod(is_multi_path[o.name], parent, obj.name, prop)}(
{% end %}\
{% when prop.isReference %}\
// ${prop.name} is reference and occurs more than once
std::shared_ptr<${prop.instanceTypeNS}> ${prop.instanceVariableName}_reference(std::make_shared<${prop.instanceTypeNS}>());
${prop.instanceVariableName}_reference->setID(${prop.argumentName});
std::shared_ptr<ome::xml::model::Reference> ref(std::static_pointer_cast<ome::xml::model::Reference>(std::make_shared<${prop.instanceTypeNS}>()));
ref->setID(${prop.argumentName});
std::shared_ptr<::${lang.omexml_model_package}::OMEModelObject> modelObject(std::static_pointer_cast<::${lang.omexml_model_package}::OMEModelObject>(${safe_accessor([{'accessor':'root'}]+accessor(obj.name, parent, prop, func=accessor_string_complex), setPropMethod(is_multi_path[o.name], parent, obj.name, prop))}));
std::shared_ptr<::${lang.omexml_model_package}::Reference> ref(std::static_pointer_cast<::${lang.omexml_model_package}::Reference>(${prop.instanceVariableName}_reference));

model->addReference(modelObject, ref);
{% end %}\
Expand Down
10 changes: 2 additions & 8 deletions xsd-fu/templates-cpp/OMEXMLModelObject.template
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@

#include <ome/xml/Document.h>
#include <ome/xml/model/ModelException.h>
#include <ome/xml/model/Reference.h>
#include <ome/xml/model/detail/Parse.h>

#include <boost/format.hpp>
Expand Down Expand Up @@ -727,10 +728,6 @@ ${customUpdatePropertyContent[prop.name]}
${klass.name}::link (std::shared_ptr<Reference>& reference,
std::shared_ptr<${lang.omexml_model_package}::OMEModelObject>& object)
{
if (${klass.parentName}::link(reference, object))
{
return true;
}
{% for prop in klass.properties.values() %}\
{% if prop.isReference %}\
if (std::dynamic_pointer_cast<${prop.name}>(reference))
Expand Down Expand Up @@ -771,10 +768,7 @@ ${customUpdatePropertyContent[prop.name]}
}
{% end %}\
{% end %}\
BOOST_LOG_SEV(logger, ome::logging::trivial::warning)
<< "Unable to handle reference of type: "
<< typeid(reference).name();
return false;
return ${klass.parentName}::link(reference, object);
}
{% end source %}\
{% if klass.langBaseType is not None %}\
Expand Down
8 changes: 1 addition & 7 deletions xsd-fu/templates-java/OMEXMLModelObject.template
Original file line number Diff line number Diff line change
Expand Up @@ -465,11 +465,6 @@ ${customUpdatePropertyContent[prop.name]}

public boolean link(Reference reference, OMEModelObject o)
{
boolean wasHandledBySuperClass = super.link(reference, o);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mtbc This is where the spurious link/ref warnings originate.

if (wasHandledBySuperClass)
{
return true;
}
{% for prop in klass.properties.values() %}\
{% if prop.isReference %}\
if (reference instanceof ${prop.name})
Expand All @@ -493,8 +488,7 @@ ${customUpdatePropertyContent[prop.name]}
}
{% end %}\
{% end %}\
LOGGER.debug("Unable to handle reference of type: {}", reference.getClass());
return false;
return super.link(reference, o);
}
{% if klass.langBaseType != 'Object' %}\
// Element's text data getter
Expand Down