Skip to content

Commit a85c011

Browse files
committed
Wrap repetitively passed data in VocabUtil class
1 parent a537734 commit a85c011

File tree

1 file changed

+161
-0
lines changed

1 file changed

+161
-0
lines changed

lxljs/vocab.js

+161
Original file line numberDiff line numberDiff line change
@@ -770,3 +770,164 @@ export function computeContainerMap(contextList) {
770770

771771
return containerMap;
772772
}
773+
774+
export class VocabUtil {
775+
constructor(vocab, context) {
776+
this.vocab = vocab;
777+
this.context = context;
778+
}
779+
780+
getTermObject(term) {
781+
return getTermObject(term, this.vocab, this.context);
782+
}
783+
784+
filterOwnClasses(classArray) {
785+
return filterOwnClasses(classArray, this.context);
786+
}
787+
788+
getBaseClasses(classId) {
789+
return getBaseClasses(classId, this.vocab, this.context);
790+
}
791+
792+
getBaseClassesFromArray(typeArray) {
793+
return getBaseClassesFromArray(typeArray, this.vocab, this.context);
794+
}
795+
796+
isSubClassOf(classId, baseClassId) {
797+
return isSubClassOf(classId, baseClassId, this.vocab, this.context);
798+
}
799+
800+
getRecordType(mainEntityType) {
801+
return getRecordType(mainEntityType, this.vocab, this.context);
802+
}
803+
804+
/*
805+
hasCategory(term, category, resources) {
806+
return hasCategory(term, category, resources);
807+
}
808+
*/
809+
810+
getTermByType(type, settings) {
811+
return getTermByType(type, this.vocab, this.context, settings);
812+
}
813+
814+
getTermFromLabel(label, language) {
815+
return getTermFromLabel(label, language, this.vocab);
816+
}
817+
818+
getPropertyTypes(propertyId) {
819+
return getPropertyTypes(propertyId, this.vocab, this.context);
820+
}
821+
822+
getAllEnumerationTypesFor(onProp) {
823+
return getAllEnumerationTypesFor(onProp, this.vocab);
824+
}
825+
826+
getRestrictions(restrictionProperty, entityType, property) {
827+
return getRestrictions(restrictionProperty, entityType, property, this.vocab, this.context);
828+
}
829+
830+
getRange(propertyId) {
831+
return getRange(propertyId, this.vocab, this.context);
832+
}
833+
834+
getSubClasses(classname) {
835+
return getSubClasses(classname, this.vocabClasses, this.context);
836+
}
837+
838+
getAllSubClasses(classArray) {
839+
return getAllSubClasses(classArray, this.vocabClasses, this.context);
840+
}
841+
842+
getSubClassChain(classname) {
843+
return getSubClassChain(classname, this.vocabClasses, this.context);
844+
}
845+
846+
getRangeFull(key, vocabClasses) {
847+
return getRangeFull(key, this.vocab, this.context, vocabClasses);
848+
}
849+
850+
getDomainList(property) {
851+
return getDomainList(property, this.vocab, this.context);
852+
}
853+
854+
getProperties(classId, vocabProperties) {
855+
return getProperties(classId, this.vocabClasses, vocabProperties, this.context);
856+
}
857+
858+
getContextValue(propertyId) {
859+
return getContextValue(propertyId, this.key, this.context);
860+
}
861+
862+
propIsRepeatable(propertyId) {
863+
return propIsRepeatable(propertyId, this.context);
864+
}
865+
866+
getPropertiesFromArray(typeArray, vocabProperties) {
867+
return getPropertiesFromArray(typeArray, this.vocabClasses, vocabProperties, this.context);
868+
}
869+
870+
isEmbedded(classId, settings) {
871+
return isEmbedded(classId, this.vocab, settings, this.context);
872+
}
873+
874+
isDistinct(classId, settings) {
875+
return isDistinct(classId, this.vocab, settings, this.context);
876+
}
877+
878+
isExtractable(classId, settings) {
879+
return isExtractable(classId, this.vocab, settings, this.context);
880+
}
881+
882+
getMappedPropertyByContainer(property) {
883+
return getMappedPropertyByContainer(property, this.container, this.context);
884+
}
885+
886+
getBaseUriFromPrefix(prefix) {
887+
return getBaseUriFromPrefix(prefix, this.context);
888+
}
889+
890+
getContainedBaseUri(uri) {
891+
return getContainedBaseUri(uri, this.context);
892+
}
893+
894+
getContainedPrefix(uri) {
895+
return getContainedPrefix(uri, this.context);
896+
}
897+
898+
getPrefixFromBaseUri(baseUri) {
899+
return getPrefixFromBaseUri(baseUri, this.context);
900+
}
901+
902+
getValidTemplates(type, templateCollection, vocabClasses) {
903+
return getValidTemplates(type, templateCollection, vocabClasses, this.context);
904+
}
905+
906+
/*
907+
isAbstract(termObject) {
908+
return isAbstract(termObject);
909+
}
910+
*/
911+
912+
getTree(term, counter = 0, parentChainString = '') {
913+
return getTree(term, this.vocab, this.context, counter, parentChainString);
914+
}
915+
916+
flattenTree(termArray, language) {
917+
return flattenTree(termArray, this.vocab, this.context, language);
918+
}
919+
920+
printTree(term) {
921+
return printTree(term, this.vocab, this.context);
922+
}
923+
924+
preprocessContext() {
925+
return preprocessContext(this.context);
926+
}
927+
928+
/*
929+
computeContainerMap(contextList) {
930+
return computeContainerMap(contextList);
931+
}
932+
*/
933+
}

0 commit comments

Comments
 (0)