Skip to content

Commit

Permalink
feat(ontology): support partOf value to create book res class (DEV-180)…
Browse files Browse the repository at this point in the history
… (#634)

* feat(ontology): init part of property

* feat(ontology): support part of and seqnum

* feat(ontology): support partOf property

* docs(ontology): update section with part of

* chore(docs): update docs

Co-authored-by: mdelez <60604010+mdelez@users.noreply.github.com>
  • Loading branch information
kilchenmann and mdelez committed Jan 18, 2022
1 parent 9812b9c commit 3051a67
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 12 deletions.
Binary file added docs/assets/images/Fig42.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 15 additions & 5 deletions docs/user-guide/project.md
Expand Up @@ -106,23 +106,24 @@ Now you can add properties to your class. Your pdf of a book has a number of pag
Theoretically, you have two options now. If you defined properties before, you may simply add them here (second option in the following image). If you just start adding properties, you have to choose `Create new from type`.
![Two options for defining properties.](../assets/images/Fig12.png)

By hovering over `Create new from type`, a new dialog box appears:
By hovering over `Create new from type`, a new menu box appears:
![Create new property.](../assets/images/Fig13.png)

You can choose from a selection of the following basic types with various subtypes:

- Text (*Short*, *Paragraph*, *Rich Text*)
- List (*Dropdown*)
- Boolean (*Yes/No* selection; checkbox)
- Date / Time (*Date*, *Timestamp*, *Time sequence*)
- Number (*Integer*, *Decimal*)
- Link / Relation (*Resource Class*, *External URL*)
- Number (*Integer*, *Decimal*, *Page number*)
- Link / Relation (*Link to Class*, *Part of Class*, *External URL*)
- Location (*Place*; a [geonames-identifier](https://www.geonames.org/))
- Shape (*color*)

Since in our example you want to add a property for the number of pages of your book, you choose `Number`. Now you will see that you can either choose the type `Decimal` or `Integer` for your property.
Since in our example you want to add a property for the number of pages of your book, you choose `Number`. Now you will see that you can either choose the type `Decimal`, `Integer` or `Page number` for your property.
![Property types.](../assets/images/Fig14.png)

Page numbers have no decimal places, thus you will selecet `Integer` as type for your property. The following window pops up:
Page numbers have no decimal places, thus you will selecet `Integer` (or `Page number` which is a special case (s. [next section](#correct-property-selection-in-case-of-special-classes))) as the type for your property. The following window pops up:
![Property of integer type.](../assets/images/Fig15.png)

In the field *Property label* add for example *Number of pages*, in the comment section you should add a meaningful explanation. It might also make sense to toggle `Required field?` since every PDF Document consists of a number of pages. If you toggle it, the number of pages MUST be given if you add data to the class *Book* - it would then be a required field, not an optional one and data could only be saved if you add the number of pages.
Expand All @@ -133,6 +134,15 @@ If you want to define a property which can have more than one value, you should
Now you should see the new property in the box as seen below:
![Layout after the creation of the property.](../assets/images/Fig17.png)

### Correct property selection in case of special classes

#### Book class with pages as individual classes

If you have single digitized pages of a book in your project, they can be defined as its own individual *Still image* class type. In this case the — let's call it *Page* — class needs two specific properties to work the correct way. One is the `part of`-property which can be found in the list of properties in the section "Link / Relation". This property points to the main class called *Book* (which should be defined first and is type of *Object without representation*). The second property is for the `page number` definition and is also necessary. This default property can be found in the list of properties in the section called "Number".

This is how a book and the page class could look like:
![Page class as part of Book class](../assets/images/Fig42.png)

### Define Lists
One of the possible property types to choose from is *List*. Lists are very useful if you want to use controlled vocabulary to describe something. Typical examples are keywords. In your book example it may be useful to define a property which describes to which category of literature your pdf of a book belongs. **Before** you can add a property of type *List* to your data model, you have to define this list. For the definiton of a list you have to change to the `Lists` tab:
![List tab.](../assets/images/Fig34.png)
Expand Down
22 changes: 20 additions & 2 deletions src/app/project/ontology/default-data/default-properties.ts
Expand Up @@ -139,7 +139,7 @@ export class DefaultProperties {
group: 'Number',
elements: [
{
icon: 'money',
icon: '60fps',
label: 'Integer',
description: 'Integer value',
subPropOf: Constants.HasValue,
Expand All @@ -155,6 +155,15 @@ export class DefaultProperties {
objectType: Constants.DecimalValue,
guiEle: Constants.SalsahGui + Constants.HashDelimiter + 'Spinbox', // 'Number',
group: 'Number'
},
{
icon: 'filter_3',
label: 'Page number',
description: 'The page number is needed for page classes in case of part of properties',
subPropOf: Constants.KnoraApiV2 + Constants.HashDelimiter + 'seqnum',
objectType: Constants.IntValue,
guiEle: Constants.SalsahGui + Constants.HashDelimiter + 'Spinbox', // 'Number',
group: 'Number'
}
]
},
Expand All @@ -163,13 +172,22 @@ export class DefaultProperties {
elements: [
{
icon: 'link',
label: 'Resource class',
label: 'Link to class',
description: 'Refers to a resource class',
subPropOf: Constants.HasLinkTo,
objectType: Constants.LinkValue,
guiEle: Constants.SalsahGui + Constants.HashDelimiter + 'Searchbox', // 'Autocomplete',
group: 'Link / Relation'
},
{
icon: 'extension',
label: 'Part of class',
description: 'Is part of a resource class',
subPropOf: Constants.KnoraApiV2 + Constants.HashDelimiter + 'isPartOf',
objectType: Constants.LinkValue,
guiEle: Constants.SalsahGui + Constants.HashDelimiter + 'Searchbox', // 'Autocomplete',
group: 'Relation'
},
{
icon: 'language',
label: 'External URL',
Expand Down
Expand Up @@ -485,9 +485,9 @@ export class PropertyFormComponent implements OnInit {
newResProp.guiElement = this.propertyInfo.propType.guiEle;
newResProp.subPropertyOf = [this.propertyInfo.propType.subPropOf];

if (this.propertyInfo.propType.subPropOf === Constants.HasLinkTo) {
if (this.propertyInfo.propType.subPropOf === Constants.HasLinkTo || this.propertyInfo.propType.subPropOf === Constants.KnoraApiV2 + Constants.HashDelimiter + 'isPartOf') {
newResProp.objectType = guiAttr;
// newResProp.subjectType = classIri;
newResProp.subjectType = this.resClassIri;
} else {
newResProp.objectType = this.propertyInfo.propType.objectType;
}
Expand Down
Expand Up @@ -181,8 +181,7 @@ export class ResourceClassInfoComponent implements OnInit {

const propToDisplay = ontoProps.find(obj =>
obj.id === hasProp.propertyIndex &&
((!obj.isLinkValueProperty) || (obj.subjectType && !obj.subjectType.includes('Standoff')))

((obj.subjectType && !obj.subjectType.includes('Standoff')) && obj.objectType !== Constants.LinkValue || !obj.isLinkValueProperty)
);

if (propToDisplay) {
Expand All @@ -199,7 +198,7 @@ export class ResourceClassInfoComponent implements OnInit {
// find corresponding default property to have more prop info
if (availableProp.guiElement) {
for (const group of this.defaultProperties) {
if (availableProp.subPropertyOf[0] !== Constants.HasLinkTo) {
if (availableProp.subPropertyOf[0] !== Constants.HasLinkTo && availableProp.subPropertyOf[0] !== Constants.KnoraApiV2 + Constants.HashDelimiter + 'isPartOf') {
propType = group.elements.find(i =>
i.guiEle === availableProp.guiElement && i.objectType === availableProp.objectType
);
Expand Down

0 comments on commit 3051a67

Please sign in to comment.