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

feat: activate not-exists for link prop #992

Merged
merged 1 commit into from
Apr 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -323,45 +323,45 @@ describe('SpecifyPropertyValueComponent', () => {
).toEqual(8);
});

// it('should set the correct comparison operators for a linking property type (on top level)', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this dead code now? I'd delete it if it's not used.

Copy link
Collaborator Author

@Vijeinath Vijeinath Apr 12, 2023

Choose a reason for hiding this comment

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

No, I uncommented it so the test is valid for the added notexists case

// const resProps = MockOntology.mockReadOntology(
// 'http://0.0.0.0:3333/ontology/0001/anything/v2'
// ).getPropertyDefinitionsByType(ResourcePropertyDefinition);
//
// testHostComponent.propertyDef = resProps.filter(
// (propDef) =>
// propDef.id ===
// 'http://0.0.0.0:3333/ontology/0001/anything/v2#hasOtherThing'
// )[0];
//
// testHostFixture.detectChanges();
//
// expect(
// testHostComponent.specifyProperty.comparisonOperators.length
// ).toEqual(5);
// expect(testHostComponent.topLevel).toBeTrue();
// });

// it('should set the correct comparison operators for a linking property type (not on top level)', () => {
// const resProps = MockOntology.mockReadOntology(
// 'http://0.0.0.0:3333/ontology/0001/anything/v2'
// ).getPropertyDefinitionsByType(ResourcePropertyDefinition);
//
// testHostComponent.propertyDef = resProps.filter(
// (propDef) =>
// propDef.id ===
// 'http://0.0.0.0:3333/ontology/0001/anything/v2#hasOtherThing'
// )[0];
//
// testHostComponent.topLevel = false;
//
// testHostFixture.detectChanges();
//
// expect(
// testHostComponent.specifyProperty.comparisonOperators.length
// ).toEqual(4);
// expect(testHostComponent.topLevel).toBeFalse();
// });
it('should set the correct comparison operators for a linking property type (on top level)', () => {
const resProps = MockOntology.mockReadOntology(
'http://0.0.0.0:3333/ontology/0001/anything/v2'
).getPropertyDefinitionsByType(ResourcePropertyDefinition);

testHostComponent.propertyDef = resProps.filter(
(propDef) =>
propDef.id ===
'http://0.0.0.0:3333/ontology/0001/anything/v2#hasOtherThing'
)[0];

testHostFixture.detectChanges();

expect(
testHostComponent.specifyProperty.comparisonOperators.length
).toEqual(5);
expect(testHostComponent.topLevel).toBeTrue();
});

it('should set the correct comparison operators for a linking property type (not on top level)', () => {
const resProps = MockOntology.mockReadOntology(
'http://0.0.0.0:3333/ontology/0001/anything/v2'
).getPropertyDefinitionsByType(ResourcePropertyDefinition);

testHostComponent.propertyDef = resProps.filter(
(propDef) =>
propDef.id ===
'http://0.0.0.0:3333/ontology/0001/anything/v2#hasOtherThing'
)[0];

testHostComponent.topLevel = false;

testHostFixture.detectChanges();

expect(
testHostComponent.specifyProperty.comparisonOperators.length
).toEqual(4);
expect(testHostComponent.topLevel).toBeFalse();
});

it('should init the MatSelect and MatOptions correctly', async () => {
const select = await loader.getHarness(MatSelectHarness);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,19 @@ export class SpecifyPropertyValueComponent implements OnChanges, OnDestroy {

case Constants.Resource: // tODO: Match is only available on top level
this.comparisonOperators = this.topLevel
? [new Equals(), new NotEquals(), new Exists(), new Match()]
: [new Equals(), new NotEquals(), new Exists()];
? [
new Equals(),
new NotEquals(),
new Exists(),
new NotExists(),
new Match(),
]
: [
new Equals(),
new NotEquals(),
new Exists(),
new NotExists(),
];
break;

case Constants.IntValue:
Expand Down Expand Up @@ -214,7 +225,10 @@ export class SpecifyPropertyValueComponent implements OnChanges, OnDestroy {
case Constants.IntervalValue:
case Constants.GeonameValue:
case Constants.TimeValue:
this.comparisonOperators = [new Exists(), new NotExists()];
this.comparisonOperators = [
new Exists(),
new NotExists(),
];
break;

default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2246,54 +2246,54 @@ OFFSET 0
).toHaveBeenCalledTimes(1);
});

// it('Gravsearch query string with no existing LINK property values', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above

// const prop = MockOntology.mockReadOntology(
// 'http://0.0.0.0:3333/ontology/0001/anything/v2'
// ).properties[
// 'http://0.0.0.0:3333/ontology/0001/anything/v2#hasOtherThing'
// ] as ResourcePropertyDefinition;
//
// const value = new ComparisonOperatorAndValue(
// new NotExists(),
// new ValueLiteral(undefined, 'http://api.knora.org/ontology/knora-api/v2#Resource')
// );
//
// const propWithVal = new PropertyWithValue(prop, value, false);
//
// const gravsearch = gravSearchGenerationServ.createGravsearchQuery([propWithVal], 'http://0.0.0.0:3333/ontology/0001/anything/v2#Thing', 0);
//
// const expectedGravsearch = `
// PREFIX knora-api: <http://api.knora.org/ontology/knora-api/v2#>
// CONSTRUCT {
//
// ?mainRes knora-api:isMainResource true .
//
// ?mainRes <http://0.0.0.0:3333/ontology/0001/anything/v2#hasOtherThing> ?propVal0 .
//
// } WHERE {
//
// ?mainRes a knora-api:Resource .
//
// ?mainRes a <http://0.0.0.0:3333/ontology/0001/anything/v2#Thing> .
//
// FILTER NOT EXISTS {
// ?mainRes <http://0.0.0.0:3333/ontology/0001/anything/v2#hasOtherThing> ?propVal0 .
//
//
// }
//
//
//
// }
//
// OFFSET 0
// `;
//
// expect(gravsearch).toEqual(expectedGravsearch);
// expect(
// searchParamsServiceSpy.changeSearchParamsMsg
// ).toHaveBeenCalledTimes(1);
// });
it('Gravsearch query string with no existing LINK property values', () => {
const prop = MockOntology.mockReadOntology(
'http://0.0.0.0:3333/ontology/0001/anything/v2'
).properties[
'http://0.0.0.0:3333/ontology/0001/anything/v2#hasOtherThing'
] as ResourcePropertyDefinition;

const value = new ComparisonOperatorAndValue(
new NotExists(),
new ValueLiteral(undefined, 'http://api.knora.org/ontology/knora-api/v2#Resource')
);

const propWithVal = new PropertyWithValue(prop, value, false);

const gravsearch = gravSearchGenerationServ.createGravsearchQuery([propWithVal], 'http://0.0.0.0:3333/ontology/0001/anything/v2#Thing', 0);

const expectedGravsearch = `
PREFIX knora-api: <http://api.knora.org/ontology/knora-api/v2#>
CONSTRUCT {

?mainRes knora-api:isMainResource true .

?mainRes <http://0.0.0.0:3333/ontology/0001/anything/v2#hasOtherThing> ?propVal0 .

} WHERE {

?mainRes a knora-api:Resource .

?mainRes a <http://0.0.0.0:3333/ontology/0001/anything/v2#Thing> .

FILTER NOT EXISTS {
?mainRes <http://0.0.0.0:3333/ontology/0001/anything/v2#hasOtherThing> ?propVal0 .


}



}

OFFSET 0
`;

expect(gravsearch).toEqual(expectedGravsearch);
expect(
searchParamsServiceSpy.changeSearchParamsMsg
).toHaveBeenCalledTimes(1);
});

it('Gravsearch query string with LIST property equaling a value', () => {
const prop = MockOntology.mockReadOntology(
Expand Down