Skip to content

Commit

Permalink
feat!: implement text decluttering
Browse files Browse the repository at this point in the history
  • Loading branch information
Vijeinath committed Jul 4, 2023
1 parent f1d1397 commit 95cf56b
Show file tree
Hide file tree
Showing 11 changed files with 54 additions and 270 deletions.
7 changes: 3 additions & 4 deletions src/api/v2/ontology/ontologies-endpoint.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { MockAjaxCall } from "../../../../test/mockajaxcall";
import { KnoraApiConfig } from "../../../knora-api-config";
import { KnoraApiConnection } from "../../../knora-api-connection";
import { ApiResponseError } from "../../../models/api-response-error";
import { Constants } from "../../../models/v2/Constants";
import { Cardinality } from "../../../models/v2/ontologies/class-definition";
import { CreateOntology } from "../../../models/v2/ontologies/create/create-ontology";
Expand All @@ -16,11 +15,11 @@ import { CanDoResponse } from "../../../models/v2/ontologies/read/can-do-respons
import { ReadOntology } from "../../../models/v2/ontologies/read/read-ontology";
import {
ResourceClassDefinition,
ResourceClassDefinitionWithAllLanguages
ResourceClassDefinitionWithAllLanguages,
} from "../../../models/v2/ontologies/resource-class-definition";
import {
ResourcePropertyDefinition,
ResourcePropertyDefinitionWithAllLanguages
ResourcePropertyDefinitionWithAllLanguages,
} from "../../../models/v2/ontologies/resource-property-definition";
import { StandoffClassDefinition } from "../../../models/v2/ontologies/standoff-class-definition";
import { SystemPropertyDefinition } from "../../../models/v2/ontologies/system-property-definition";
Expand Down Expand Up @@ -865,7 +864,7 @@ describe("OntologiesEndpoint", () => {
"http://schema.org/name"
];

newResProp.objectType = Constants.TextValue;
newResProp.objectType = Constants.UnformattedTextValue;

newResProp.subjectType = "http://0.0.0.0:3333/ontology/0001/anything/v2#Thing";

Expand Down
8 changes: 4 additions & 4 deletions src/api/v2/resource/resources-endpoint.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import { CreateIntervalValue } from "../../../models/v2/resources/values/create/
import { CreateLinkValue } from "../../../models/v2/resources/values/create/create-link-value";
import { CreateListValue } from "../../../models/v2/resources/values/create/create-list-value";
import {
CreateTextValueAsString,
CreateTextValueAsXml
CreateFormattedTextValue,
CreateUnformattedTextValue,
} from "../../../models/v2/resources/values/create/create-text-value";
import { CreateTimeValue } from "../../../models/v2/resources/values/create/create-time-value";
import { CreateUriValue } from "../../../models/v2/resources/values/create/create-uri-value";
Expand Down Expand Up @@ -237,11 +237,11 @@ describe("ResourcesEndpoint", () => {
const linkVal = new CreateLinkValue();
linkVal.linkedResourceIri = "http://rdfh.ch/0001/a-thing";

const textValStandoff = new CreateTextValueAsXml();
const textValStandoff = new CreateFormattedTextValue();
textValStandoff.xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<text><p><strong>this is</strong> text</p> with standoff</text>";
textValStandoff.mapping = "http://rdfh.ch/standoff/mappings/StandardMapping";

const textValString = new CreateTextValueAsString();
const textValString = new CreateUnformattedTextValue();
textValString.text = "this is text without standoff";

const uriVal = new CreateUriValue();
Expand Down
48 changes: 24 additions & 24 deletions src/api/v2/values/values-endpoint.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import { CreateIntervalValue } from "../../../models/v2/resources/values/create/
import { CreateLinkValue } from "../../../models/v2/resources/values/create/create-link-value";
import { CreateListValue } from "../../../models/v2/resources/values/create/create-list-value";
import {
CreateTextValueAsString,
CreateTextValueAsXml
CreateFormattedTextValue,
CreateUnformattedTextValue,
} from "../../../models/v2/resources/values/create/create-text-value";
import { CreateTimeValue } from "../../../models/v2/resources/values/create/create-time-value";
import { CreateUriValue } from "../../../models/v2/resources/values/create/create-uri-value";
Expand All @@ -39,8 +39,8 @@ import { ReadIntervalValue } from "../../../models/v2/resources/values/read/read
import { ReadLinkValue } from "../../../models/v2/resources/values/read/read-link-value";
import { ReadListValue } from "../../../models/v2/resources/values/read/read-list-value";
import {
ReadTextValueAsString,
ReadTextValueAsXml
ReadFormattedTextValue,
ReadUnformattedTextValue,
} from "../../../models/v2/resources/values/read/read-text-value";
import { ReadTimeValue } from "../../../models/v2/resources/values/read/read-time-value";
import { UpdateBooleanValue } from "../../../models/v2/resources/values/update/update-boolean-value";
Expand All @@ -55,8 +55,8 @@ import { UpdateIntervalValue } from "../../../models/v2/resources/values/update/
import { UpdateLinkValue } from "../../../models/v2/resources/values/update/update-link-value";
import { UpdateListValue } from "../../../models/v2/resources/values/update/update-list-value";
import {
UpdateTextValueAsString,
UpdateTextValueAsXml
UpdateFormattedTextValue,
UpdateUnformattedTextValue,
} from "../../../models/v2/resources/values/update/update-text-value";
import { UpdateTimeValue } from "../../../models/v2/resources/values/update/update-time-value";
import { UpdateUriValue } from "../../../models/v2/resources/values/update/update-uri-value";
Expand Down Expand Up @@ -335,7 +335,7 @@ describe("ValuesEndpoint", () => {

knoraApiConnection.v2.values.getValue("http://rdfh.ch/0001/H6gBWUuJSuuO-CilHV8kQw", "SZyeLLmOTcCCuS3B0VksHQ").subscribe(
(res: ReadResource) => {
const textVal = res.getValuesAs("http://0.0.0.0:3333/ontology/0001/anything/v2#hasText", ReadTextValueAsString);
const textVal = res.getValuesAs("http://0.0.0.0:3333/ontology/0001/anything/v2#hasText", ReadUnformattedTextValue);
expect(textVal.length).toEqual(1);
expect(textVal[0].text).toEqual("test");

Expand Down Expand Up @@ -364,7 +364,7 @@ describe("ValuesEndpoint", () => {

knoraApiConnection.v2.values.getValue("http://rdfh.ch/0001/H6gBWUuJSuuO-CilHV8kQw", "rvB4eQ5MTF-Qxq0YgkwaDg").subscribe(
(res: ReadResource) => {
const textVal = res.getValuesAs("http://0.0.0.0:3333/ontology/0001/anything/v2#hasRichtext", ReadTextValueAsXml);
const textVal = res.getValuesAs("http://0.0.0.0:3333/ontology/0001/anything/v2#hasRichtext", ReadFormattedTextValue);
expect(textVal.length).toEqual(1);
expect(textVal[0].xml).toEqual("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<text><p>test with <strong>markup</strong></p></text>");
expect(textVal[0].mapping).toEqual("http://rdfh.ch/standoff/mappings/StandardMapping");
Expand Down Expand Up @@ -947,7 +947,7 @@ describe("ValuesEndpoint", () => {

it("should update a text value as string", done => {

const updateTextVal = new UpdateTextValueAsString();
const updateTextVal = new UpdateUnformattedTextValue();

updateTextVal.id = "http://rdfh.ch/0001/a-thing/values/pHuFhBelROGexp2IhaLQAg";
updateTextVal.text = "text without standoff updated";
Expand All @@ -962,7 +962,7 @@ describe("ValuesEndpoint", () => {
knoraApiConnection.v2.values.updateValue(updateResource).subscribe(
(res: WriteValueResponse) => {
expect(res.id).toEqual("http://rdfh.ch/0001/a-thing/values/updated");
expect(res.type).toEqual(Constants.TextValue);
expect(res.type).toEqual(Constants.UnformattedTextValue);
done();
}
);
Expand All @@ -971,7 +971,7 @@ describe("ValuesEndpoint", () => {

request.respondWith(MockAjaxCall.mockResponse(WriteValueMocks.mockUpdateValueResponse(
"http://rdfh.ch/0001/a-thing/values/updated",
Constants.TextValue,
Constants.UnformattedTextValue,
"uuid")));

expect(request.url).toBe("http://0.0.0.0:3333/v2/values");
Expand All @@ -990,7 +990,7 @@ describe("ValuesEndpoint", () => {

it("should update a text value as XML", done => {

const updateTextVal = new UpdateTextValueAsXml();
const updateTextVal = new UpdateFormattedTextValue();

updateTextVal.id = "http://rdfh.ch/0001/a-thing/values/I4OWMilwQwaYvaN5wlUIqg";
updateTextVal.xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<text>\n This updated text links to another <a class=\"salsah-link\" href=\"http://rdfh.ch/0001/another-thing\">resource</a>.\n</text>";
Expand All @@ -1006,7 +1006,7 @@ describe("ValuesEndpoint", () => {
knoraApiConnection.v2.values.updateValue(updateResource).subscribe(
(res: WriteValueResponse) => {
expect(res.id).toEqual("http://rdfh.ch/0001/a-thing/values/updated");
expect(res.type).toEqual(Constants.TextValue);
expect(res.type).toEqual(Constants.FormattedTextValue);
done();
}
);
Expand All @@ -1015,7 +1015,7 @@ describe("ValuesEndpoint", () => {

request.respondWith(MockAjaxCall.mockResponse(WriteValueMocks.mockUpdateValueResponse(
"http://rdfh.ch/0001/a-thing/values/updated",
Constants.TextValue,
Constants.FormattedTextValue,
"uuid")));

expect(request.url).toBe("http://0.0.0.0:3333/v2/values");
Expand Down Expand Up @@ -1353,7 +1353,7 @@ describe("ValuesEndpoint", () => {

it("should update an integer value with a comment", done => {

const updateTextVal = new UpdateTextValueAsString();
const updateTextVal = new UpdateUnformattedTextValue();

updateTextVal.id = "http://rdfh.ch/0001/a-thing/values/NVRw0-VkQL2YdI_kgkV33Q";
updateTextVal.text = "text without standoff updated";
Expand Down Expand Up @@ -1832,7 +1832,7 @@ describe("ValuesEndpoint", () => {

it("should create a text value as string", done => {

const updateTextVal = new CreateTextValueAsString();
const updateTextVal = new CreateUnformattedTextValue();

updateTextVal.text = "text without standoff";

Expand All @@ -1846,7 +1846,7 @@ describe("ValuesEndpoint", () => {
knoraApiConnection.v2.values.createValue(createResource).subscribe(
(res: WriteValueResponse) => {
expect(res.id).toEqual("http://rdfh.ch/0001/H6gBWUuJSuuO-CilHV8kQw/values/created");
expect(res.type).toEqual(Constants.TextValue);
expect(res.type).toEqual(Constants.UnformattedTextValue);
done();
}
);
Expand All @@ -1855,7 +1855,7 @@ describe("ValuesEndpoint", () => {

request.respondWith(MockAjaxCall.mockResponse(WriteValueMocks.mockCreateValueResponse(
"http://rdfh.ch/0001/H6gBWUuJSuuO-CilHV8kQw/values/created",
Constants.TextValue,
Constants.UnformattedTextValue,
"uuid",
"2019-01-09T15:45:54.502951Z")));

Expand All @@ -1872,7 +1872,7 @@ describe("ValuesEndpoint", () => {

it("should create a text value as XML", done => {

const createTextVal = new CreateTextValueAsXml();
const createTextVal = new CreateFormattedTextValue();

createTextVal.xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<text>\n This text links to another <a class=\"salsah-link\" href=\"http://rdfh.ch/0001/another-thing\">resource</a>.\n And this <strong id=\"link_id\">strong value</strong> is linked by this <a class=\"internal-link\" href=\"#link_id\">link</a>\n</text>";
createTextVal.mapping = "http://rdfh.ch/standoff/mappings/StandardMapping";
Expand All @@ -1887,7 +1887,7 @@ describe("ValuesEndpoint", () => {
knoraApiConnection.v2.values.createValue(updateResource).subscribe(
(res: WriteValueResponse) => {
expect(res.id).toEqual("http://rdfh.ch/0001/H6gBWUuJSuuO-CilHV8kQw/values/created");
expect(res.type).toEqual(Constants.TextValue);
expect(res.type).toEqual(Constants.FormattedTextValue);
done();
}
);
Expand All @@ -1896,7 +1896,7 @@ describe("ValuesEndpoint", () => {

request.respondWith(MockAjaxCall.mockResponse(WriteValueMocks.mockCreateValueResponse(
"http://rdfh.ch/0001/H6gBWUuJSuuO-CilHV8kQw/values/created",
Constants.TextValue,
Constants.FormattedTextValue,
"uuid",
"2019-01-09T15:45:54.502951Z")));

Expand Down Expand Up @@ -2193,7 +2193,7 @@ describe("ValuesEndpoint", () => {

it("should create a text value with a comment", done => {

const createTextVal = new CreateTextValueAsString();
const createTextVal = new CreateUnformattedTextValue();

createTextVal.text = "this is a text value that has a comment";
createTextVal.valueHasComment = "this is a comment";
Expand All @@ -2208,7 +2208,7 @@ describe("ValuesEndpoint", () => {
knoraApiConnection.v2.values.createValue(updateResource).subscribe(
(res: WriteValueResponse) => {
expect(res.id).toEqual("http://rdfh.ch/0001/H6gBWUuJSuuO-CilHV8kQw/values/created");
expect(res.type).toEqual(Constants.TextValue);
expect(res.type).toEqual(Constants.UnformattedTextValue);
done();
}
);
Expand All @@ -2217,7 +2217,7 @@ describe("ValuesEndpoint", () => {

request.respondWith(MockAjaxCall.mockResponse(WriteValueMocks.mockCreateValueResponse(
"http://rdfh.ch/0001/H6gBWUuJSuuO-CilHV8kQw/values/created",
Constants.TextValue,
Constants.UnformattedTextValue,
"uuid",
"2019-01-09T15:45:54.502951Z")));

Expand Down
20 changes: 6 additions & 14 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,9 @@ export { ReadIntervalValue } from "./models/v2/resources/values/read/read-interv
export { ReadLinkValue } from "./models/v2/resources/values/read/read-link-value";
export { ReadListValue } from "./models/v2/resources/values/read/read-list-value";
export {
ReadTextValue,
ReadTextValueAsString,
ReadTextValueAsHtml,
ReadTextValueAsXml,
ReadTextValue,
ReadUnformattedTextValue,
ReadFormattedTextValue
ReadFormattedTextValue,
} from "./models/v2/resources/values/read/read-text-value";
export { ReadUriValue } from "./models/v2/resources/values/read/read-uri-value";
export { ReadTimeValue } from "./models/v2/resources/values/read/read-time-value";
Expand All @@ -213,12 +210,9 @@ export { UpdateIntValue } from "./models/v2/resources/values/update/update-int-v
export { UpdateIntervalValue } from "./models/v2/resources/values/update/update-interval-value";
export { UpdateLinkValue } from "./models/v2/resources/values/update/update-link-value";
export { UpdateListValue } from "./models/v2/resources/values/update/update-list-value";
export {
UpdateTextValueAsString,
UpdateTextValueAsXml,
UpdateTextValueAsHtml,
export {
UpdateFormattedTextValue,
UpdateUnformattedTextValue,
UpdateFormattedTextValue
} from "./models/v2/resources/values/update/update-text-value";
export { UpdateUriValue } from "./models/v2/resources/values/update/update-uri-value";
export { UpdateTimeValue } from "./models/v2/resources/values/update/update-time-value";
Expand All @@ -243,11 +237,9 @@ export { CreateIntValue } from "./models/v2/resources/values/create/create-int-v
export { CreateIntervalValue } from "./models/v2/resources/values/create/create-interval-value";
export { CreateLinkValue } from "./models/v2/resources/values/create/create-link-value";
export { CreateListValue } from "./models/v2/resources/values/create/create-list-value";
export {
CreateTextValueAsString,
CreateTextValueAsXml,
export {
CreateFormattedTextValue,
CreateUnformattedTextValue,
CreateFormattedTextValue
} from "./models/v2/resources/values/create/create-text-value";
export { CreateUriValue } from "./models/v2/resources/values/create/create-uri-value";
export { CreateTimeValue } from "./models/v2/resources/values/create/create-time-value";
Expand Down
1 change: 0 additions & 1 deletion src/models/v2/Constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ export class Constants {
static IntervalValue = Constants.KnoraApiV2 + Constants.HashDelimiter + "IntervalValue";
static ListValue = Constants.KnoraApiV2 + Constants.HashDelimiter + "ListValue";
static ListNode = Constants.KnoraApiV2 + Constants.HashDelimiter + "ListNode";
static TextValue = Constants.KnoraApiV2 + Constants.HashDelimiter + "TextValue";
static FormattedTextValue = Constants.KnoraApiV2 + Constants.HashDelimiter + "FormattedTextValue";
static UnformattedTextValue = Constants.KnoraApiV2 + Constants.HashDelimiter + "UnformattedTextValue";
static CustomFormattedTextValue = Constants.KnoraApiV2 + Constants.HashDelimiter + "CustomFormattedTextValue";
Expand Down
Loading

0 comments on commit 95cf56b

Please sign in to comment.