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

Issue with uniqueness validation #16

Open
pefribeiro opened this issue Aug 6, 2021 · 0 comments
Open

Issue with uniqueness validation #16

pefribeiro opened this issue Aug 6, 2021 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@pefribeiro
Copy link
Contributor

For an unknown reason, the calculation of c in:

def checkUniquenessInProject(NamedElement o) {
val project = o.eResource.URI.segment(1)
val c = rds.allResourceDescriptions.filter[rd|rd.URI.segment(1) == project].map [ rd |
rd.getExportedObjects(o.eClass, qnp.getFullyQualifiedName(o), false).toSet
].reduce[p1, p2|p1.addAll(p2); return p1]
val s = c.size
if (s > 1) {
warning(
'''There is more than one element with name '«qnp.getFullyQualifiedName(o)»'.''',
RoboChartPackage.Literals.NAMED_ELEMENT__NAME,
'UniqueQualifiedName'
)
}
}
def checkUniquenessWithoutProject(NamedElement o) {
val c = rds.allResourceDescriptions.map [ rd |
rd.getExportedObjects(o.eClass, qnp.getFullyQualifiedName(o), false).toSet
].reduce[p1, p2|p1.addAll(p2); return p1]
val s = c.size
if (s > 1) {
warning(
'''There is more than one element with name '«qnp.getFullyQualifiedName(o)»'.''',
RoboChartPackage.Literals.NAMED_ELEMENT__NAME,
'UniqueQualifiedName'
)
}
}

can be null. I don't fully understand why the method checkUniqueness is overridden:

override def checkUniqueness(NamedElement o) {
val eResource = o.eResource
if (o.eResource.URI.segmentCount > 1) {
o.checkUniquenessInProject
} else {
o.checkUniquenessWithoutProject
}
}

and how o.eResource.URI.segmentCount can provide a meaningful decision.

@pefribeiro pefribeiro added the bug Something isn't working label Aug 6, 2021
@pefribeiro pefribeiro self-assigned this Aug 6, 2021
pefribeiro added a commit that referenced this issue Aug 6, 2021
Addressing issue #16 by eliminating NullPointerException.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant