Comments (10)
from lyo.core.
Interesting. I guess marshalling of a ServiceProvider is done quite often, but no one has yet encoutered this problem before, since it is not often one needs to unmarshall a ServiceProvider.
Have a fix in mind? It should be easy to find and fix.
from lyo.core.
I will investigate. This is really strange b/c the getCreated returns a single Date anyway. I suspect the about
setter is not called properly and it creates a subsequent mess in the persisted graph.
from lyo.core.
Got it. The error is triggered by me trying to add the same SP to a Set multiple times:
@Override
public void addServiceProvider(final ServiceProvider sp) {
final Collection<ServiceProvider> serviceProviders = getServiceProviders();
serviceProviders.add(sp);
try {
store.putResources(twinsGraphURI, serviceProviders);
} catch (StoreAccessException e) {
throw new IllegalStateException("Unable to persist the new SP in the KB");
}
}
I was expecting the Set implementation to catch that but the problem is that it relies on equals
and hashCode
implementations. This brings us back to an old question. I wanted for a long time to define the equals
and hashCode
just in terms of the about
URI. I think both @jadelkhoury and @jamsden were uneasy about ignoring all other properties.
I think it makes sense to expect the check
if(serviceProviders.contains(sp)) {
}
to return true if a Set already contains a resource with the same URI. If we don't agree to add such equality implementations, I would have to reimplement my Set
as a Map<URI, SP>
and then do a check on the about URIs. I am not sure if that's the better way or just a hack. The Map would also make it harder to work with the collections returned by Lyo Store.
P.S. Apologies for a duplicate.
from lyo.core.
Just to add some material for thinking: formally speaking, the equals method has to satisfy the equivalence relations described here: https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html#equals(java.lang.Object)
The one I am proposing will satisfy all the rules, it will just not be as discriminating as possible.
from lyo.core.
An about URI in this case is a perfect example of a Natural identifier as explained here: https://vladmihalcea.com/how-to-implement-equals-and-hashcode-using-the-jpa-entity-identifier/
from lyo.core.
@jadelkhoury @jamsden @yashkhatri what's your opinion?
from lyo.core.
I think it makes sense to define equal in terms of the about URI.
from lyo.core.
I definitely agree, AbstractResource should implements equals and hashcode based on the about URI. Sometimes I had have to implement my own Comparator in order to keep unique resources into a Set... I suggest to modify Link class also to implement equals and hashcode in terms of the value property.
from lyo.core.
Nothing wrong with the annotations on the ServiceProvider class, closing.
Equality checking will be handled in #82.
from lyo.core.
Related Issues (20)
- AbstractOslcRdfXmlProvider.getSerializtionLanguage() doesn't recognize MediaType.TEXT_XML HOT 2
- Move JenaModelException to Core HOT 8
- MessageBodyWriter not found for media type=application/rdf+xml, type=class [Ljava.lang.Object HOT 1
- OSLC Providers incorrectly raise 500 error
- Removing all logic from AbstractOslcRdfXmlProvider::isWritable causes wrong JAX-RS Provider to handle arrays HOT 2
- Fix broken build HOT 2
- Remove URISyntaxException from core.trs.TrackedResourceSet#setChangeLog HOT 1
- Replace IllegalState/IllegalArgument exceptions in JMH with LyoModelException HOT 1
- JMH silently fails with unknown typed literals HOT 1
- CQ Jena 3.12 HOT 1
- Upgrade to Jena 3.12
- CQ httpclient 4.5.9 HOT 2
- CQ guava 28 JRE HOT 1
- Unable to use abstract types HOT 3
- JMH unmarshall return nulls in spring boot application
- changeLogs are loosing their URIs HOT 8
- Create an update site and plugins out of the Lyo libraries HOT 2
- Web.xml not generated HOT 1
- Allow client and server to be generated separately HOT 1
- Successful build failing in Jenkins HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lyo.core.