-
Notifications
You must be signed in to change notification settings - Fork 0
/
jassa-ui-angular-edit.min.js
9 lines (8 loc) · 34.8 KB
/
jassa-ui-angular-edit.min.js
1
2
3
4
5
6
7
8
9
/*
* jassa-ui-angular-edit
* https://github.com/GeoKnow/Jassa-UI-Angular
* Version: 0.9.0-SNAPSHOT - 2016-01-13
* License: BSD
*/
angular.module("ui.jassa.edit",["ui.jassa.geometry-input","ui.jassa.rdf-term-input","ui.jassa.rex","ui.jassa.sync"]),angular.module("ui.jassa.geometry-input",[]).provider("GeocodingLookup",function(){this.config={service:["Nominatim","LinkedGeoData"],defaultService:!1},this.defaultServices={Nominatim:{label:"Nominatim",serviceType:"rest",url:"http://nominatim.openstreetmap.org/search/?format=json&polygon_text=1&q=",data:{format:"json",polygon_text:"1",q:"%KEYWORD%"},fnSuccess:function(a){var b=a.data,c=[];for(var d in b)b[d].hasOwnProperty("geotext")&&c.push({firstInGroup:!1,wkt:b[d].geotext,label:b[d].display_name,group:"Nominatim"});return c}},LinkedGeoData:{label:"LinkedGeoData",serviceType:"sparql",endpoint:"http://linkedgeodata.org/vsparql",graph:"http://linkedgeodata.org/ne/",prefix:{ogc:"http://www.opengis.net/ont/geosparql#",geom:"http://geovocab.org/geometry#"},query:'{ Graph <http://linkedgeodata.org/ne/> { ?s a <http://linkedgeodata.org/ne/ontology/Country> ; rdfs:label ?l ; geom:geometry [ ogc:asWKT ?g ] FILTER regex(?l, "%KEYWORD%", "i") } }',sponateTemplate:[{id:"?s",label:"?l",wkt:"?g"}],limit:5,fnSuccess:function(a){var b=a,c=[];if(b.length>0)for(var d in b)c.push({firstInGroup:!1,wkt:b[d].val.wkt,label:b[d].val.label,group:"LinkedGeoData"});return c}}},this.userServices={},this.$get=function(){var a=angular.injector(["ng"]),b=a.get("$http"),c=a.get("$q"),d={promisesMetaInformation:[],promises:[]},e={};for(var f in this.config.service){var g=this.config.service[f];e[g]=this.defaultServices[g]}_(this.userServices).isEmpty()||(this.config.defaultService?_(e).extend(this.userServices):e=this.userServices);var h=function(a,b){var c=d.promises.length;d.promisesMetaInformation.push({label:a,promiseID:c}),d.promises.push(b)},i=function(){return d},j=function(){d.promises=[],d.promisesMetaInformation=[]},k=function(a,b){b=b=angular.isArray(b)?b:[b];var c=jassa.service.SparqlServiceBuilder.http(a,b,{type:"POST"}).cache().virtFix().paginate(1e3).pageExpand(100).create();return c},l=function(a,b){return"rest"===a.serviceType?m(a,b):"sparql"===a.serviceType?n(a,b):void 0},m=function(a,c){var d=o(a.data).replace(/%KEYWORD%/gi,c);return b({method:"GET",url:a.url+"?"+d,cache:!0,headers:{Accept:"application/json","Content-Type":"application/json"}})},n=function(a,b){var c=k(a.endpoint,a.graph),d=new jassa.sponate.StoreFacade(c,_(a.prefix).defaults(jassa.vocab.InitialContext)),e=a.query.replace(/%KEYWORD%/gi,b),f=a.limit||10;return d.addMap({name:"sparqlService",template:a.sponateTemplate,from:e}),d.sparqlService.getListService().fetchItems(null,f)},o=function(a){var b=[];for(var c in a)b.push(c+"="+a[c]);return b.join("&")},p=function(a){return a=_(a).flatten(),a=_(a).groupBy("group"),a=_(a).map(function(a){return a[0].firstInGroup=!0,a}),a=_(a).flatten(),a=_(a).value()};return{findByKeyword:function(a){j();for(var b in e){var d=e[b],f=l(d,a);h(b,f)}var g=i(),k=c.all(g.promises).then(function(a){var b=[];for(var c in a){var d=a[c],f=g.promisesMetaInformation[c].label,h=e[f].fnSuccess(d);b.push(h)}return p(b)},function(a){throw console.log("Error during request",a),new Error("Error during request:"+JSON.stringify(a))});return k}}},this.setService=function(a){this.userServices[a.label]=a},this.setConfiguration=function(a){_(this.config).extend(a)}}).directive("geometryInput",["$http","$q","GeocodingLookup",function(a,b,c){var d=1;return{restrict:"EA",require:"?ngModel",templateUrl:"template/geometry-input/geometry-input.html",replace:!0,scope:{bindModel:"=ngModel",ngModelOptions:"=?",geocodingServices:"=geocodingServices"},controller:["$scope",function(a){a.ngModelOptions=a.ngModelOptions||{},a.geometry="point",a.isLoading=!1,a.fetchResults=function(a){return c.findByKeyword(a)},a.onSelectGeocode=function(b){console.log("onselect",b),a.bindModel=b.wkt}}],compile:function(a,b){return{pre:function(a,b,c,e){function f(){var a="openlayers-map-"+d++;b.find(".map").attr("id",a),n=new OpenLayers.Map(a);var c=new OpenLayers.Layer.WMS("OpenLayers WMS","http://vmap0.tiles.osgeo.org/wms/vmap0?",{layers:"basic"});p=new OpenLayers.Control.Panel({displayClass:"olControlEditingToolbar"});var e={methods:["vertex","edge"],layers:[r]},f=OpenLayers.Util.getParameters(window.location.href).renderer;f=f?[f]:OpenLayers.Layer.Vector.prototype.renderers,r=new OpenLayers.Layer.Vector("Vector Layer",{renderers:f}),n.addLayers([c,r]),n.addControl(new OpenLayers.Control.LayerSwitcher),n.addControl(new OpenLayers.Control.MousePosition),r.events.on({sketchcomplete:g}),q=new OpenLayers.Format.WKT,o={point:new OpenLayers.Control.DrawFeature(r,OpenLayers.Handler.Point,{displayClass:"olControlDrawFeaturePoint",handlerOptions:e}),line:new OpenLayers.Control.DrawFeature(r,OpenLayers.Handler.Path,{displayClass:"olControlDrawFeaturePath",handlerOptions:e}),polygon:new OpenLayers.Control.DrawFeature(r,OpenLayers.Handler.Polygon,{displayClass:"olControlDrawFeaturePolygon",handlerOptions:e}),box:new OpenLayers.Control.DrawFeature(r,OpenLayers.Handler.RegularPolygon,{displayClass:"olControlDrawFeatureBox",handlerOptions:_.extend({sides:4,irregular:!0},e)}),modify:new OpenLayers.Control.ModifyFeature(r,{snappingOptions:e,onModificationStart:k,onModification:l,onModificationEnd:m})},p.addControls(o.modify),n.addControl(p),p.activateControl(o.modify);for(var h in o)n.addControl(o[h]);n.setCenter(new OpenLayers.LonLat(0,0),4)}function g(b){var c=h(b.feature);a.bindModel=c,a.$apply()}function h(a){var b=q.write(a);return b=b.replace(/,/g,", ")}function i(b){var c,d=b||a.bindModel,e=q.read(d);if(e){e.constructor!=Array&&(e=[e]);for(var f=0;f<e.length;++f)c?c.extend(e[f].geometry.getBounds()):c=e[f].geometry.getBounds();r.addFeatures(e),n.zoomToExtent(c);e.length>1?"s":""}else console.log("Bad WKT")}function j(){var b=o[a.geometry];for(var c in o)b=o[c],a.geometry==c?b.activate():b.deactivate()}function k(b){o[a.geometry].deactivate()}function l(b){var c=h(b);a.bindModel=c,e.$setDirty(),a.$$phase&&a.$apply()}function m(b){o[a.geometry].activate()}e.$name=a.$eval(c.name),a.searchString="";var n,o,p,q,r;a.$watch(function(){return a.bindModel},function(b,c){r.destroyFeatures(),a.bindModel=b,null!=a.bindModel&&i()}),a.$watch(function(){return a.geometry},function(a){j()}),f();var s=o[a.geometry];s.activate()}}}}}]);var rdfTermInputCounter=0;angular.module("ui.jassa.rdf-term-input",[]).directive("rdfTermInput",["$parse",function(a){var b={iri:"http://iri",plainLiteral:"http://plainLiteral",typedLiteral:"http://typedLiteral"};return{restrict:"EA",priority:0,require:"ngModel",templateUrl:"template/rdf-term-input/rdf-term-input.html",replace:!0,scope:{bindModel:"=ngModel",ngModelOptions:"=?",logo:"@?",langs:"=?",datatypes:"=?",rightButton:"=?"},controller:["$scope",function(a){a.forms={},a.state=a.$state||{},a.ngModelOptions=a.ngModelOptions||{},this.setRightButton=function(){a.rightButton=!0},a.vocab=b,a.termTypes=[{id:b.iri,displayLabel:"IRI"},{id:b.plainLiteral,displayLabel:"plain"},{id:b.typedLiteral,displayLabel:"typed"}];var c=[{id:"",displayLabel:"(none)"},{id:"en",displayLabel:"en"},{id:"de",displayLabel:"de"},{id:"fr",displayLabel:"fr"},{id:"zh",displayLabel:"zh"},{id:"ja",displayLabel:"ja"}];a.langs=a.langs||c;var d=Object.keys(jassa.vocab.xsd);a.datatypes=d.map(function(a){var b=jassa.vocab.xsd[a].getUri();return{id:b,displayLabel:jassa.util.UriUtils.extractLabel(b)}}),a.addLanguage=function(a){return{id:a,displayLabel:a}},a.addDatatype=function(a){return{id:a,displayLabel:a}}}],compile:function(a,c){return{pre:function(a,c,d,e){e.$name=a.$eval(d.name);var f=function(){var b=[a.forms.type.value,a.forms.datatype.value,a.forms.lang.value,a.forms.value.value];return b},g=function(){var a=f(),b=!a.some(function(a){return!a.$pristine});return b};a.$watch(function(){return e.$pristine},function(a){if(a){var b=f();b.forEach(function(a){a.$setPristine()})}}),a.$watch(g,function(a){a?e.$setPristine():e.$setDirty()}),a.rightButton=!1,a.setRightButton=function(){a.rightButton=!0};var h=function(){var c,d=a.state,e=d.type;switch(null!=e||null==d.value&&null==d.datatype&&null==d.lang||(e=b.plainLiteral),e){case b.iri:c={type:"uri",value:d.value};break;case b.plainLiteral:c={type:"literal",value:d.value,lang:d.lang,datatype:""};break;case b.typedLiteral:c={type:"literal",value:d.value,datatype:d.datatype||jassa.vocab.xsd.xstring.getUri()};break;default:c={}}return c},i=function(a){var c,d=a;try{c=jassa.rdf.NodeFactory.createFromTalisRdfJson(d)}catch(e){}var f;if(c){if(c.isUri())f={type:b.iri,value:c.getUri()};else if(c.isLiteral()){var g=c.getLiteralDatatypeUri(),h=!jassa.util.ObjectUtils.isEmptyString(g);f=h?{type:b.typedLiteral,value:c.getLiteralLexicalForm(),datatype:g}:{type:b.plainLiteral,value:c.getLiteralLexicalForm(),lang:c.getLiteralLanguage()}}}else f={};return f};a.$watch(function(){var b=a.bindModel;return b},function(b){if(b){var c=i(b);a.state=c;for(var d in a.termTypes)if(a.termTypes[d].id===a.state.type){a.termTypes.selected=a.termTypes[d];break}var e=!1;for(var f in a.datatypes)if(a.datatypes[f].id===a.state.datatype){a.datatypes.selected=a.datatypes[f],e=!0;break}if(!e){var g=new jassa.rdf.PrefixMappingImpl,h={id:a.state.datatype,displayLabel:g.shortForm(a.state.datatype)};a.datatypes.push(h),a.datatypes.selected=h}var j=!1;for(var k in a.langs)if(a.langs[k].id===a.state.lang){a.langs.selected=a.langs[k],j=!0;break}if(!j){var l={id:a.state.lang,displayLabel:a.state.lang};a.langs.push(l),a.langs.selected=l}}else;},!0),a.$watch(function(){var a=h();return a},function(b){b&&angular.copy(b,a.bindModel)},!0)}}}}}]);var ArrayTool=Jassa.ext.Class.create({filter:function(){throw new Error("not implemented")},project:function(a){throw new Error("not implemented")},inject:function(a,b){throw new Error("not implemented")},generate:function(){throw new Error("not implemented")}}),RdfObjectFilter=Jassa.ext.Class.create({initialize:function(a,b,c){this.types=termTypes||null,this.langs=b||null,this.datatypes=c||null}}),ArrayToolRdfObject=Jassa.ext.Class.create({initialize:function(a,b,c){this.rdfObjectFilter=a,this.defaultTalisRdfJson=b,this.projectAttr=c||"value"},deriveDefaults:function(){var a=this.rdfObjectFilter,b={type:a.types?a.types[0]:null,lang:a.langs?a.langs[0]:null,datatype:a.datatypes?a.datatypes[0]:null,value:null};return b},arrayContains:function(a,b){var c=null==a?!0:a.indexOf(b)>-1;return c},filter:function(a){var b=this.rdfObjectFilter,c=arrayContains(b.types,a.type),d=arrayContains(b.langs,a.lang),e=(arrayContains(b.datatypes,a.datatype),c&&d&&acceptDataype);return e},project:function(a,b){var c=a[this.projectAttr];return c},inject:function(a,b){a[this.projectAttr]=b},generate:function(){var a={};return ObjectUtils.extend(a,this.defaultTalisRdfJson),a}}),SimpleArray=Jassa.ext.Class.create({}),SimpleArrayRdfInverse=Jassa.ext.Class.create({initialize:function(a,b,c){this.talisRdfJson=a,this.propertyStr=b,this.sourceRdfObject=c}}),ArrayWrapper=Jassa.ext.Class.create(SimpleArray,{initialize:function(a){this.baseArray=a},get:function(a){var b=this.baseArray[a];return b},set:function(a,b){this.baseArray[a]=b},push:function(a){this.baseArray.push(a)},pop:function(){var a=this.baseArray.pop();return a},size:function(){var a=this.baseArray.length;return a}}),SimpleArrayVirt=Jassa.ext.Class.create({initialize:function(a,b){this.baseArrayFn=a,this.arrayTool=b;var c=this;this.itemPredicate=function(a){var b=c.arrayTool.filter(a);return b}},remove:function(a){var b=this.baseArrayFn(),c=ArrayUtils.createIndexMapVirtToBase(b,this.itemPredicate),d=a<c.length?c[a]:null;null!=d&&(b.remove(d,1),this.baseArrayFn(b))},set:function(a,b){var c=this.baseArrayFn(),d=ArrayUtils.createIndexMapVirtToBase(c,this.itemPredicate),e=a<d.length?d[a]:null;if(null!=e)for(var f=a-offset,g=0;f>g;++g){var h=this.arrayTool.generate();c.push(h),d.push(c.length)}var i=c.get(e);this.arrayTool.inject(i,b)},push:function(a){var b=this.size();this.set(b,a)},get:function(a){var b=this.baseArrayFn(),c=ArrayUtils.createIndexMapVirtToBase(b,this.itemPredicate),d=a<c.length?c[a]:null,e=d?b.get(d):null,f=this.arrayTool.project(e);return f},size:function(){var a=ArrayUtils.createIndexMapVirtToBase(baseArray,this.itemPredicate),b=a.length;return b}});SimpleArrayVirt.createVirtArrayForRdf=function(a,b,c){};var ArrayUtils={createIndexMapVirtToBase:function(a,b){for(var c=[],d=this.baseArrayFn(),e=0;e<d.size();++e){var f=d.get(e),g=b(f);g&&c.push(e)}return c},syncToSrc:function(a,b,c){b.forEach(function(b,d){var e=c[d];null==e?(e=a.length,srcArray.push(b),c[d]=e):srcArray[e]=b})},syncToDest:function(a,b,c){c.forEach(function(c,d){var e=a[c];b[d]=e})}},parsePrefixes=function(a){var b=a?a instanceof PrefixMappingImpl?a:new PrefixMappingImpl(a):new PrefixMappingImpl;return b},getModelAttribute=function(a){var b=["ngModel","model"],c=Object.keys(a),d=null;return b.some(function(a){var b=c.indexOf(a)>=0;return b&&(d=a),b}),d},createCompileComponent=function(a,b,c,d){return{pre:function(e,f,g,h){var i=g[a],j=c(i),k=j.assign;d||syncAttr(c,e,g,a);var l=h[0],m=h[2],n=l.allocSlot();n.entry={},e.$on("$destroy",function(){n.release(),q()}),n.entry.key=createCoordinate(e,b);var o=j(e);o&&jassa.rdf.TalisRdfJsonUtils.setValueAt(l.getOverride(),n.entry.key,o);var p=function(){var a=n.entry.key,b=e.rexContext.dirty,c=b[a]=b[a]||{};c[n.id]=!0},q=function(a){a=a||n.entry.key;var b=e.rexContext.dirty,c=b[a];c&&(delete c[n.id],0===Object.keys(c).length&&delete b[a])},r=function(a){var c;if("deleted"===b)c=!0;else{a=a||n.entry.key;var d=e.rexContext.dirty,f=d[a];c=!!f}return c};if(m){var s=function(){m.$pristine?q():p()};e.$watch(s)}e.$watch(function(){var a=createCoordinate(e,b);return a},function(a,b){if(a&&!a.equals(b)){var c=r(b);n.entry.key=a;var d=c?getEffectiveValue(e.rexContext,b):getEffectiveValue(e.rexContext,a);jassa.rdf.TalisRdfJsonUtils.setValueAt(l.getOverride(),a,d),q(b)}},!0),d||e.$watch(function(){var a=n.entry.key,b=getEffectiveValue(e.rexContext,a);return b},function(a){n.entry.key;k&&k(e,a)},!0),e.$watch(function(){var a=j(e);return a},function(a){var b=n.entry.key;jassa.rdf.TalisRdfJsonUtils.setValueAt(l.getOverride(),b,a)},!0)}}},createCompileArray=function(){return{pre:function(a,b,c,d){var e=d[0],f=e.allocSlot();f.triples=[],a.$on("$destroy",function(){f.release()}),syncAttr($parse,a,c,"rexNavPredicate"),syncAttr($parse,a,c,"rexNavInverse"),syncAttr($parse,a,c,"rexFilterTermtype"),syncAttr($parse,a,c,"rexFilterLang"),syncAttr($parse,a,c,"rexFilterDatatype"),syncAttr($parse,a,c,"rexDefaultTermtype"),syncAttr($parse,a,c,"rexDefaultLang"),syncAttr($parse,a,c,"rexDefaultDatatype"),syncAttr($parse,a,c,"rexOffset"),syncAttr($parse,a,c,"rexLimit");var g=b.attr("rex-nav-targets"),h=$dddi(a);h.register(g,["rexSparqlService","rexSubject","rexNavPredicate","?rexNavInverse",function(b,c,d,e){var f=a.rexPrefixMapping||new jassa.rdf.PrefixMappingImpl(jassa.vocab.InitialContext);c=f.expandPrefix(c),d=f.expandPrefix(d);var g=jassa.sparql.VarUtils.s,h=jassa.rdf.NodeFactory.createUri(d),i=jassa.rdf.NodeFactory.createUri(c),j=e?new jassa.rdf.Triple(g,h,i):new jassa.rdf.Triple(i,h,g),k=new jassa.sparql.Concept(new jassa.sparql.ElementGroup([new jassa.sparql.ElementTriplesBlock([j]),new jassa.sparql.ElementFilter(new jassa.sparql.E_IsIri(new jassa.sparql.ExprVar(g)))]),g),l=jassa.sparql.ConceptUtils.createQueryList(k),m=new jassa.service.ListServiceSparqlQuery(b,l,k.getVar()),n=m.fetchItems().then(function(a){var b=a.map(function(a){var b=a.key.getUri();return b});return b});return n}]);var i=function(b){var c=a.rexPrefixMapping||new jassa.rdf.PrefixMappingImpl(jassa.vocab.InitialContext),d=jassa.rdf.NodeFactory.createUri(c.expandPrefix(a.rexSubject)),e=jassa.rdf.NodeFactory.createUri(c.expandPrefix(a.rexNavPredicate)),g=b.map(function(b){var f=jassa.rdf.NodeFactory.createUri(c.expandPrefix(b)),g=a.rexNavInverse?new jassa.rdf.Triple(f,e,d):new jassa.rdf.Triple(d,e,f);return g});f.triples=g};a.$watchCollection(g,function(a){a&&i(a)})}}},assembleTalisRdfJson=function(a){var b={},c=a.entries();return c.forEach(function(c){var d=c.key,e=new jassa.rdf.Coordinate(d.s,d.p,d.i,"deleted"),f=a.get(e);if(!f){var g=c.val,h=b,i=h[d.s]=h[d.s]||{},j=i[d.p]=i[d.p]||[],k=j[d.i]=j[d.i]||{};k[d.c]=g}}),b},processPrefixes=function(a,b){var c={},d=a,e=Object.keys(d);return e.forEach(function(a){var c=d[a],e=Object.keys(c);e.forEach(function(a){var d=c[a];d.forEach(function(a){var c=b;if(c)if("uri"===a.type){var d=a.value;a.value=c.expandPrefix(d)}else if("literal"===a.type&&null!=a.datatype){var e=a.datatype;a.datatype=c.expandPrefix(e)}})})}),c},createCoordinate=function(a,b){return new jassa.rdf.Coordinate(a.rexSubject,a.rexPredicate,a.rexObject,b)},talisRdfJsonToEntries=function(a){var b=[],c=a,d=Object.keys(c);return d.forEach(function(a){var d=c[a],e=Object.keys(d);e.forEach(function(c){var e=d[c],f=0;e.forEach(function(d){var e=Object.keys(d);e.forEach(function(e){var g=d[e],h=new jassa.rdf.Coordinate(a,c,f,e);b.push({key:h,val:g})}),++f})})}),b},talisRdfJsonToCoordinates=function(a){var b=talisRdfJsonToEntries(a),c=[];return b.forEach(function(a){c.push(a.key)}),c},diff=function(a,b){var c=new jassa.util.HashSet;return b.forEach(function(b){var d=a.contains(b);d||c.add(b)}),c},setDiff=function(a,b){var c={added:diff(a,b),removed:diff(b,a)};return c},getEffectiveValue=function(a,b){var c=a.override?jassa.rdf.TalisRdfJsonUtils.getValueAt(a.override,b):null;return null==c&&(c=a.json?jassa.rdf.TalisRdfJsonUtils.getValueAt(a.json,b):null),c},syncAttr=function(a,b,c,d,e,f){var g;if(d in c){var h=c[d],i=a(h),j=function(){var a=i(b),c=f?f(a):a;return c};b.$watch(j,function(a){b[d]=a},e),g=j(),b[d]=g}else g=void 0;return g},setEleAttrDefaultValue=function(a,b,c,d){var e=a.attr(c);if(!e){e=d,a.attr(c,e);var f=b.$normalize(c);b[f]=e}return e},rexIsPredicateNew=function(a,b,c){var d=a.base[b],e=a.json[b],f=d?c in d:!1,g=e?c in e:!1,h=g&&!f;return h};angular.module("ui.jassa.rex",["dddi","ui.select"]).filter("toArray",["$dddi",function(a){return a.utils.wrapArrayFn(function(a){var b;return b=a instanceof Object?_.map(a,function(a,b){return{key:b,val:a}}):a})}]).filter("stableArray",["$dddi",function(a){return a.utils.wrapArrayFn(function(a){return a})}]).filter("rexPredicateNew",function(){return function(a,b,c){if(!a)return a;var d=b.rexContext,e=b.rexSubject;return c=c||"isNew",a.forEach(function(a){var b=a.key,f=rexIsPredicateNew(d,e,b);a[c]=f}),a}}),angular.module("ui.jassa.rex").directive("rexContext",["$parse","$q","$dddi","$log",function(a,b,c,d){return{priority:30,restrict:"A",scope:!0,require:"rexContext",controller:["$scope",function(a){a.rexContext=a.rexContext||{},this.$scope=a,this.getOverride=function(){var b=a.rexContext,c=b?b.override:null;return c},this.nextSlot=0,a.rexChangeSlots={},this.allocSlot=function(){var b=this.nextSlot++,c="slot_"+b,d=a.rexChangeSlots[c]={id:c,release:function(){delete a.rexChangeSlots[c]}};return d},this.getSlots=function(){var b=a.rexChangeSlots,c=Object.keys(b),d=c.map(function(a){var c=b[a];return c});return d},this.getEnforcedGraph=function(){var a=new jassa.rdf.GraphImpl,b=this.getSlots();return b.forEach(function(b){var c=b.triples;c&&a.addAll(c)}),a},this.getReferencedCoordinates=function(){var a=new jassa.util.HashSet,b=this.getSlots();return b.forEach(function(b){var c=b.entry,d=c?c.key:null;null!=d&&a.add(d)}),a}}],compile:function(e,f){return setEleAttrDefaultValue(e,f,"rex-context","rexContext"),{pre:function(e,f,g,h){syncAttr(a,e,g,"rexContext");var i=function(a){a.override=a.override||{},a.dirty=a.dirty||{},a.refSubjects=a.refSubjects||{},a.srcGraph=a.srcGraph||new jassa.rdf.GraphImpl,a.checkpoint=function(){},resetData=function(){},a.reset=function(){var c=l().then(function(){var b=h.getReferencedCoordinates();return b.forEach(function(b){var c=(getEffectiveValue(a,b),jassa.rdf.TalisRdfJsonUtils.getValueAt(a.json,b));jassa.rdf.TalisRdfJsonUtils.setValueAt(a.override,b,c)}),!0});return c=b.when(c).then(angular.noop).then(angular.noop,function(){d.error("error while rexContext.reset")})},a.renamePredicate=function(b,c,d){var e=h.getOverride(),f=a.json;jassa.rdf.TalisRdfJsonUtils.renamePredicate(e,b,c,d),jassa.rdf.TalisRdfJsonUtils.renamePredicate(f,b,c,d)}},j=function(a){var b=[];return function(){for(var c=a();b.length;)b.pop();return b.push.apply(b,c),b}},k=j(function(){var a=Object.keys(e.rexContext.refSubjects);return a}),l=function(){var a,b=e.rexLookup,c=e.rexSparqlService,d=e.rexContext.subjects;if(b&&c&&d){var f=d.map(function(a){return jassa.rdf.NodeFactory.createUri(a)}),g=new jassa.service.LookupServiceGraphSparql(c),h=g.lookup(f);a=h.then(function(a){var b=e.rexContext,c=b.baseGraph=b.baseGraph||new jassa.rdf.GraphImpl;a.forEach(function(a,b){var d=new jassa.rdf.Triple(b,null,null);c.removeMatch(d),c.addAll(a)})})}else a=Promise.resolve();return a=a.then(function(){var a=e.rexContext;a.base=a.baseGraph?jassa.io.TalisRdfJsonUtils.triplesToTalisRdfJson(a.baseGraph):{},a.json=angular.copy(a.base)})};e.$watchCollection("[rexSparqlService, rexLookup, rexPrefixMapping]",function(){b.when(l()).then(angular.noop).then(angular.noop,function(){d.error("error while watching rexSparqlService, rexLookup, rexPrefixMapping")})}),e.$watchCollection(k,function(a){e.rexContext.subjects=a,console.log("Subjects: "+JSON.stringify(a)),b.when(l()).then(angular.noop).then(angular.noop,function(){d.error("error while watching getSubjects")})}),e.$watch(function(){return e.rexContext},function(a){i(a)}),i(e.rexContext);var m=function(){var a=e.rexContext,b=a?a.baseGraph:null;return b};e.$watch(function(){var a=m(),b=a?a.hashCode():null;return b},function(){var a=m();e.rexContext.base=a?jassa.io.TalisRdfJsonUtils.triplesToTalisRdfJson(a):{}});var n=function(a){var b=(h.getOverride(),new jassa.util.HashMap);return a.forEach(function(a){var c=getEffectiveValue(e.rexContext,a);b.put(a,c)}),b},o=function(a,b){var c=assembleTalisRdfJson(a);processPrefixes(c,b);var d=jassa.io.TalisRdfJsonUtils.talisRdfJsonToGraph(c);return d},p=function(){var a=new jassa.rdf.GraphImpl,b=h.getReferencedCoordinates();if(null!=e.rexContext.json){var c=talisRdfJsonToCoordinates(e.rexContext.json);b.addAll(c)}var d=e.rexContext.base;return b.forEach(function(b){var c=jassa.rdf.TalisRdfJsonUtils.getObjectAt(d,b);if(null!=c){var e=jassa.rdf.NodeFactory.createFromTalisRdfJson(c),f=jassa.rdf.NodeFactory.createUri(b.s),g=jassa.rdf.NodeFactory.createUri(b.p),h=new jassa.rdf.Triple(f,g,e);a.add(h)}}),a},q=function(a){var b=h.getOverride(),c=talisRdfJsonToEntries(b);c.forEach(function(c){var d=c.key,e=a.contains(d);e||jassa.rdf.TalisRdfJsonUtils.removeValueAt(b,d)})},r=new jassa.util.HashSet;e.$watch(function(){r=h.getReferencedCoordinates();var a=r.hashCode();return a},function(){q(r)},!0);var s=c(e);e.currentDataMap=new jassa.util.HashMap,s.register("currentDataMap",function(){var a=n(r);return a=a.hashCode()===e.currentDataMap.hashCode()?e.currentDataMap:a}),s.register("rexContext.graph",["currentDataMap.hashCode()",function(){var a=o(e.currentDataMap,e.rexContext.prefixMapping),b=h.getEnforcedGraph();return a.addAll(b),a}]),s.register("rexContext.targetJson",["rexContext.graph.hashCode()",function(a){var b=jassa.io.TalisRdfJsonUtils.triplesToTalisRdfJson(e.rexContext.graph);return b}]),s.register("rexContext.srcGraph",function(){var a=p();return a=a.hashCode()===e.rexContext.srcGraph.hashCode()?e.rexContext.srcGraph:a}),s.register("rexContext.diff",["rexContext.baseGraph.hashCode()","rexContext.graph.hashCode()",function(){var a=setDiff(e.rexContext.baseGraph,e.rexContext.graph);return a}])}}}}}]),angular.module("ui.jassa.rex").directive("rexDatatype",["$parse",function(a){return{priority:7,restrict:"A",scope:!0,require:["^rexContext","^rexObject","?ngModel"],controller:angular.noop,compile:function(b,c,d,e){return createCompileComponent("rexDatatype","datatype",a)}}}]),angular.module("ui.jassa.rex").directive("rexDeleted",["$parse",function(a){return{priority:7,restrict:"A",scope:!0,require:["^rexContext","^rexObject","?ngModel"],controller:angular.noop,compile:function(b,c){return createCompileComponent("rexDeleted","deleted",a)}}}]),angular.module("ui.jassa.rex").directive("rexEmitTerm",["$parse","$compile",function(a,b){return{priority:1e3,restrict:"A",scope:!0,terminal:!0,controller:angular.noop,compile:function(a,b){return{pre:function(a,b,c,d){}}}}}]),angular.module("ui.jassa.rex").directive("rexIri",["$parse","$compile",function(a,b){return{priority:900,restrict:"A",scope:!0,terminal:!0,controller:angular.noop,compile:function(a,c){return{pre:function(a,c,d,e){var f=c.attr("rex-iri");if(jassa.util.ObjectUtils.isEmptyString(f)){var g=getModelAttribute(d);f=d[g]}if(!f)throw new Error("No model provided and found");c.removeAttr("rex-iri"),c.attr("rex-object",""),c.attr("rex-termtype",'"uri"'),c.attr("rex-value",f),b(c)(a)}}}}}]),angular.module("ui.jassa.rex").directive("rexLang",["$parse",function(a){return{priority:7,restrict:"A",scope:!0,require:["^rexContext","^rexObject","?ngModel"],controller:angular.noop,compile:function(b,c,d,e){return createCompileComponent("rexLang","lang",a)}}}]),angular.module("ui.jassa.rex").directive("rexLiteral",["$parse","$compile",function(a,b){return{priority:900,restrict:"A",scope:!0,terminal:!0,controller:angular.noop,compile:function(a,c){return{pre:function(a,c,d,e){var f=c.attr("rex-literal");if(jassa.util.ObjectUtils.isEmptyString(f)){var g=getModelAttribute(d);f=d[g]}if(!f)throw new Error("No model provided and found");c.removeAttr("rex-literal"),c.attr("rex-object",""),c.attr("rex-termtype",'"literal"'),c.attr("rex-value",f),b(c)(a)}}}}}]),angular.module("ui.jassa.rex").directive("rexLookup",["$parse",function(a){return{priority:26,restrict:"A",scope:!0,require:"^rexContext",controller:angular.noop,compile:function(b,c){return{pre:function(b,c,d,e){syncAttr(a,b,d,"rexLookup")}}}}}]),angular.module("ui.jassa.rex").directive("rexNavTargets",["$parse","$q","$dddi",function(a,b,c){return{priority:10,restrict:"A",scope:!0,require:["^rexContext","^rexSubject"],controller:angular.noop,compile:function(b,d){return{pre:function(b,d,e,f){var g=f[0],h=g.allocSlot();h.triples=[],b.$on("$destroy",function(){h.release()}),syncAttr(a,b,e,"rexNavPredicate"),syncAttr(a,b,e,"rexNavInverse"),syncAttr(a,b,e,"rexFilterTermtype"),syncAttr(a,b,e,"rexFilterLang"),syncAttr(a,b,e,"rexFilterDatatype"),syncAttr(a,b,e,"rexDefaultTermtype"),syncAttr(a,b,e,"rexDefaultLang"),syncAttr(a,b,e,"rexDefaultDatatype"),syncAttr(a,b,e,"rexOffset"),syncAttr(a,b,e,"rexLimit");var i=d.attr("rex-nav-targets"),j=c(b);j.register(i,["rexSparqlService","rexSubject","rexNavPredicate","?rexNavInverse",function(a,c,d,e){var f=b.rexPrefixMapping||new jassa.rdf.PrefixMappingImpl(jassa.vocab.InitialContext);c=f.expandPrefix(c),d=f.expandPrefix(d);var g=jassa.sparql.VarUtils.s,h=jassa.rdf.NodeFactory.createUri(d),i=jassa.rdf.NodeFactory.createUri(c),j=e?new jassa.rdf.Triple(g,h,i):new jassa.rdf.Triple(i,h,g),k=new jassa.sparql.Concept(new jassa.sparql.ElementGroup([new jassa.sparql.ElementTriplesBlock([j]),new jassa.sparql.ElementFilter(new jassa.sparql.E_IsIri(new jassa.sparql.ExprVar(g)))]),g),l=jassa.sparql.ConceptUtils.createQueryList(k),m=new jassa.service.ListServiceSparqlQuery(a,l,k.getVar()),n=m.fetchItems().then(function(a){var b=a.map(function(a){var b=a.key.getUri();return b});return b});return n}]);var k=function(a){var c=b.rexPrefixMapping||new jassa.rdf.PrefixMappingImpl(jassa.vocab.InitialContext),d=jassa.rdf.NodeFactory.createUri(c.expandPrefix(b.rexSubject)),e=jassa.rdf.NodeFactory.createUri(c.expandPrefix(b.rexNavPredicate)),f=a.map(function(a){var f=jassa.rdf.NodeFactory.createUri(c.expandPrefix(a)),g=b.rexNavInverse?new jassa.rdf.Triple(f,e,d):new jassa.rdf.Triple(d,e,f);return g});h.triples=f};b.$watchCollection(i,function(a){a&&k(a)})}}}}}]),angular.module("ui.jassa.rex").directive("rexObject",["$parse",function(a){return{priority:13,restrict:"A",scope:!0,require:["^rexContext","^rexPredicate"],controller:angular.noop,compile:function(b,c){return{pre:function(b,c,d,e){var f=e[1],g=(e[0],f.rexObjectScopes.length);d.rexObject||(d.rexObject=""+g),f.rexObjectScopes.push(b),syncAttr(a,b,d,"rexObject"),b.$on("$destroy",function(){jassa.util.ArrayUtils.removeItemStrict(f.rexObjectScopes,b)});var h=function(){var a={s:b.rexSubject,p:b.rexPredicate,i:b.rexObject};return a};b.$watch(function(){var a=h();return a},function(a){b.rexRef=a},!0),b.rexRef=h()}}}}}]),angular.module("ui.jassa.rex").directive("rexPredicate",["$parse",function(a){return{priority:17,restrict:"A",scope:!0,controller:["$scope",function(a){this.rexObjectScopes=a.rexObjectScopes=[]}],compile:function(b,c){return{pre:function(b,c,d,e){syncAttr(a,b,d,"rexPredicate",!1,function(a){var c=b.rexPrefixMapping,d=c?c.expandPrefix(a):a;return d})}}}}}]),angular.module("ui.jassa.rex").directive("rexPrefix",["$parse",function(a){return{priority:25,restrict:"A",scope:!0,require:"rexContext",controller:["$scope",function(a){a.rexPrefix=a.rexPrefix||{}}],compile:function(b,c){return setEleAttrDefaultValue(b,c,"rex-prefix","rexPrefix"),{pre:function(b,c,d,e){var f=function(a){var c,d=b.$parent.rexPrefix,e=d?d.prefixes:jassa.vocab.InitialContext;c=e?Object.create(e):{};var f=jassa.util.PrefixUtils.parsePrefixDecls(a);return angular.extend(c,f),c};syncAttr(a,b,d,"rexPrefix",!0,f);var g=function(){b.rexPrefixMapping=new jassa.rdf.PrefixMappingImpl(b.rexPrefix),b.rexContext.prefixMapping=b.rexPrefixMapping};b.$watchGroup([function(){return b.rexPrefix},function(){return b.rexContext}],function(a){g()},!0),g()}}}}}]),angular.module("ui.jassa.rex").directive("rexSparqlService",["$parse",function(a){return{priority:30,restrict:"A",scope:!0,controller:angular.noop,compile:function(b,c){return{pre:function(b,c,d,e){syncAttr(a,b,d,"rexSparqlService")}}}}}]),angular.module("ui.jassa.rex").directive("rexSubject",["$parse","$q",function(a,b){return{priority:24,restrict:"A",scope:!0,require:"^rexContext",controller:angular.noop,compile:function(b,c){return{pre:function(b,c,d,e){syncAttr(a,b,d,"rexSubject",!1,function(a){var c=b.rexPrefixMapping,d=c?c.expandPrefix(a):a;return d}),b.$on("destroy",function(){var a=e.$scope.rexContext;jassa.util.ObjectUtils.free(a.refSubjects,b.rexSubject)});var f=function(a,b){var c=e.$scope.rexContext;jassa.util.ObjectUtils.alloc(c.refSubjects,a),jassa.util.ObjectUtils.free(c.refSubjects,b)};f(b.rexSubject),b.$watch("rexSubject",f)}}}}}]),angular.module("ui.jassa.rex").directive("rexTerm",["$parse","$compile",function(a,b){return{priority:900,restrict:"A",scope:!0,terminal:!0,controller:angular.noop,compile:function(a,c){return{pre:function(a,c,d,e){var f=d.rexTerm;if(jassa.util.ObjectUtils.isEmptyString(f)){var g=getModelAttribute(d);f=d[g]}if(!f)throw new Error("No model provided and found");c.removeAttr("rex-term"),c.attr("rex-termtype",f+".type"),c.attr("rex-datatype",f+".datatype"),c.attr("rex-lang",f+".lang"),c.attr("rex-value",f+".value"),b(c)(a)}}}}}]),angular.module("ui.jassa.rex").directive("rexTermtype",["$parse",function(a){return{priority:10,restrict:"A",scope:!0,require:["^rexContext","^rexObject","?ngModel"],controller:angular.noop,compile:function(b,c){return createCompileComponent("rexTermtype","type",a)}}}]),angular.module("ui.jassa.rex").directive("rexTypeof",["$parse","$compile",function(a,b){return{priority:1e3,restrict:"A",scope:!0,terminal:!0,controller:angular.noop,compile:function(a,c){return{pre:function(a,c,d,e){var f=c.attr("rex-typeof");c.removeAttr("rex-typeof"),c.attr("rex-predicate",'"http://www.w3.org/1999/02/22-rdf-syntax-ns#type"'),c.attr("rex-iri",f),b(c)(a)}}}}}]),angular.module("ui.jassa.rex").directive("rexValue",["$parse",function(a){return{priority:4,restrict:"A",scope:!0,require:["^rexContext","^rexObject","?ngModel"],controller:angular.noop,compile:function(b,c){return createCompileComponent("rexValue","value",a)}}}]),angular.module("ui.jassa.rex").directive("rexValues",["$parse","$q","$dddi",function(a,b,c){return{priority:10,restrict:"A",scope:!0,require:["^rexContext","^rexSubject"],controller:angular.noop,
compile:function(b,d){return{pre:function(b,d,e,f){var g=f[0],h=g.allocSlot();h.triples=[],b.$on("$destroy",function(){h.release()}),syncAttr(a,b,e,"rexNavPredicate"),syncAttr(a,b,e,"rexNavInverse"),syncAttr(a,b,e,"rexFilterTermtype"),syncAttr(a,b,e,"rexFilterLang"),syncAttr(a,b,e,"rexFilterDatatype"),syncAttr(a,b,e,"rexDefaultTermtype"),syncAttr(a,b,e,"rexDefaultLang"),syncAttr(a,b,e,"rexDefaultDatatype"),syncAttr(a,b,e,"rexOffset"),syncAttr(a,b,e,"rexLimit");var i=d.attr("rex-nav-targets"),j=c(b);j.register(i,["rexSparqlService","rexSubject","rexNavPredicate","?rexNavInverse",function(a,c,d,e){var f=b.rexPrefixMapping||new jassa.rdf.PrefixMappingImpl(jassa.vocab.InitialContext);c=f.expandPrefix(c),d=f.expandPrefix(d);var g=jassa.sparql.VarUtils.s,h=jassa.rdf.NodeFactory.createUri(d),i=jassa.rdf.NodeFactory.createUri(c),j=e?new jassa.rdf.Triple(g,h,i):new jassa.rdf.Triple(i,h,g),k=new jassa.sparql.Concept(new jassa.sparql.ElementGroup([new jassa.sparql.ElementTriplesBlock([j]),new jassa.sparql.ElementFilter(new jassa.sparql.E_IsIri(new jassa.sparql.ExprVar(g)))]),g),l=jassa.sparql.ConceptUtils.createQueryList(k),m=new jassa.service.ListServiceSparqlQuery(a,l,k.getVar()),n=m.fetchItems().then(function(a){var b=a.map(function(a){var b=a.key.getUri();return b});return b});return n}]);var k=function(a){var c=b.rexPrefixMapping||new jassa.rdf.PrefixMappingImpl(jassa.vocab.InitialContext),d=jassa.rdf.NodeFactory.createUri(c.expandPrefix(b.rexSubject)),e=jassa.rdf.NodeFactory.createUri(c.expandPrefix(b.rexNavPredicate)),f=a.map(function(a){var f=jassa.rdf.NodeFactory.createUri(c.expandPrefix(a)),g=b.rexNavInverse?new jassa.rdf.Triple(f,e,d):new jassa.rdf.Triple(d,e,f);return g});h.triples=f};b.$watchCollection(i,function(a){a&&k(a)})}}}}}]);var syncHelper=function(a,b,c,d,e,f,g,h,i){var j=b[e],k=i?d(j):c(j),l=b[f],m=c(l),n=m.assign,o=b[g],p=c(o),q=function(a){return a},r=b[h],s=c(r),t=function(){var b=s(a),c=angular.isUndefined(b)?!0:b;return c},u=function(){var b=t();if(b){var c=k(a),d=p(a)||q,e=d(c);n(a,e)}};a.$watch(function(){var a=t();return a},function(a){a&&u()}),a.$watch(function(){var b=p(a);return b},function(a){a&&u()}),a.$watch(function(){var b=k(a);return b},function(a){u()},!0)};angular.module("ui.jassa.sync",[]),angular.module("ui.jassa.sync").directive("syncTemplate",["$parse","$compile",function(a,b){return{priority:1e3,restrict:"A",scope:!0,terminal:!0,controller:function(){},compile:function(a,c){return{pre:function(a,c,d,e){var f=c.attr("sync-template");if(c.removeAttr("sync-template"),c.attr("sync-source",f),c.attr("sync-source-interpolate",""),null==c.attr("sync-target")){var g=getModelAttribute(d),h=d[g];if(!h)throw new Error("No model provided and found");c.attr("sync-target",h)}null==c.attr("sync-to-target")&&c.attr("sync-to-target",""),b(c)(a)}}}}}]),angular.module("ui.jassa.sync").directive("syncToSource",["$parse","$interpolate",function(a,b){return{priority:390,restrict:"A",controller:function(){},compile:function(c,d){return{pre:function(c,d,e,f){syncHelper(c,e,a,b,"syncTarget","syncSource","syncToSource","syncToSourceCond",!1)}}}}}]),angular.module("ui.jassa.sync").directive("syncToTarget",["$parse","$interpolate",function(a,b){return{priority:390,restrict:"A",controller:function(){},compile:function(c,d){return{pre:function(c,d,e,f){var g="syncSourceInterpolate"in e;syncHelper(c,e,a,b,"syncSource","syncTarget","syncToTarget","syncToTargetCond",g)}}}}}]);