Changeset 279
- Timestamp:
- 04/15/10 17:52:44 (15 years ago)
- Location:
- trunk
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/docs/json.ebnf ¶
r278 r279 195 195 DeleteTopics = "\"topics\":" List 196 196 DeleteAssociations = "\"associations\":" Associations 197 DeleteParentTopic = "\"parent -topic\":" String198 DeleteParentName = "\"parent -name\":" Name197 DeleteParentTopic = "\"parentTopic\":" String 198 DeleteParentName = "\"parentName\":" Name 199 199 DeleteNames = "\"names\":" Names 200 200 DeleteVariants = "\"variants\":" Variants 201 201 DeleteOccurrences = "\"occurrences\":" Occurrences 202 DeleteParentAssociation = "\"parent -association\":" Association202 DeleteParentAssociation = "\"parentAssociation\":" Association 203 203 DeleteRoles = "\"roles\":" Roles 204 204 -
TabularUnified trunk/docs/xtm_json.txt ¶
r278 r279 468 468 "topics": [<psi-top-1>, <psi-top-2>, <...>], 469 469 "associations": [<association-1>, <association-2>, <...>], 470 "parent -topic": "topic-psi",471 "parent -name": <name>,470 "parentTopic": "topic-psi", 471 "parentName": <name>, 472 472 "names": [<name-1>, <name-2>, <...>], 473 473 "variants": [<variant-1>, <variant-2>, <...>], 474 474 "occurrences": [<occurrence-1>, <occurrence-2>, <...>], 475 "parent -association": <association>,475 "parentAssociation": <association>, 476 476 "roles": [<role-1>, <role-2>, <...>] 477 477 } -
TabularUnified trunk/src/ajax/css/frame.css ¶
r75 r279 28 28 } 29 29 30 tr.removeNameRow { 31 background-color: #eaeaee; 32 } 33 34 tr.removeOccurrenceRow { 35 background-color: #eaeaee; 36 } 37 38 tr.removeTopicRow { 39 background-color: #eaeaee; 40 } 41 30 42 li.errorMessage { 31 43 margin-top: 1em; … … 140 152 } 141 153 154 span.removeLink { 155 cursor: pointer; 156 font-size: 0.75em; 157 float: right; 158 margin-right: 1em; 159 } 160 161 span.removeLink:hover { 162 color:#ff7f00; 163 } 164 142 165 143 166 /* === topic frame ========================================================== */ -
TabularUnified trunk/src/ajax/javascripts/constants.js ¶
r275 r279 23 23 var OWN_URL = HOST_PREF + "isidorus"; 24 24 var SUMMARY_URL = HOST_PREF + "json/summary" 25 var MARK_AS_DELETED_URL = HOST_PREF + "mark-as-deleted"; 25 26 var TM_OVERVIEW = "/json/tmcl/overview/"; 26 27 var TIMEOUT = 10000; // const TIMEOUT = 10000 --> "const" doesn't work under IE … … 90 91 "instances" : function(){ return "instances"; }, 91 92 "subtypes" : function(){ return "subtypes"; }, 92 "topicPsis" : function(){ return "topicPsis"; } 93 "topicPsis" : function(){ return "topicPsis"; }, 94 "removeLink" : function(){ return "removeLink"; }, 95 "removeNameRow" : function(){ return "removeOccurrenceRow"; }, 96 "removeOccurrenceRow" : function(){ return "removeNameRow"; }, 97 "removeTopicRow" : function(){ return "removeTopicRow"; } 93 98 }; -
TabularUnified trunk/src/ajax/javascripts/datamodel.js ¶
r179 r279 1448 1448 }); 1449 1449 } 1450 1451 var myself = this; 1452 this.__table__.insert({"bottom" : makeRemoveLink(function(event){ 1453 makeDeleteObject("Name", myself); 1454 }, "delete Name")}); 1450 1455 } 1451 1456 catch(err){ … … 1492 1497 this.getFrame().select("tr." + CLASSES.valueFrame())[0].hide(); 1493 1498 this.getFrame().select("tr." + CLASSES.variantContainer())[0].hide(); 1499 this.getFrame().select("tr." + CLASSES.removeNameRow())[0].hide(); 1494 1500 this.__isMinimized__ = true; 1495 1501 } … … 1501 1507 this.getFrame().select("tr." + CLASSES.valueFrame())[0].show(); 1502 1508 this.getFrame().select("tr." + CLASSES.variantContainer())[0].show(); 1509 this.getFrame().select("tr." + CLASSES.removeNameRow())[0].show(); 1503 1510 this.__isMinimized__ = false; 1504 1511 } … … 1513 1520 this.getFrame().writeAttribute({"class" : CLASSES.disabled()}); 1514 1521 this.getFrame().writeAttribute({"title" : this.__cssTitle__}); 1522 this.getFrame().select("tr." + CLASSES.removeNameRow())[0].disable(); 1515 1523 this.hideAddButton(); 1516 1524 this.__disabled__ = true; … … 1524 1532 this.getFrame().writeAttribute({"class" : CLASSES.nameFrame()}); 1525 1533 this.getFrame().removeAttribute("title"); 1534 this.getFrame().select("tr." + CLASSES.removeNameRow())[0].enable(); 1526 1535 checkRemoveAddButtons(this.__owner__, 1, this.__max__, this); 1527 1536 this.__disabled__ = false; … … 1743 1752 1744 1753 1754 function makeRemoveLink (removeHandler, textContent){ 1755 var link = new Element("span", {"class" : CLASSES.removeLink()}).update(textContent); 1756 var trClass = null; 1757 switch(textContent){ 1758 case "delete Occurrence" : trClass = CLASSES.removeOccurrenceRow(); break; 1759 case "delete Topic" : trClass = CLASSES.removeTopicRow(); break; 1760 case "delete Name" : trClass = CLASSES.removeNameRow(); break; 1761 } 1762 1763 var tr = new Element("tr", {"class" : trClass}).insert(new Element("td", {"colspan" : 3}).insert(link)); 1764 if(removeHandler){ link.observe("click", removeHandler); } 1765 return tr; 1766 } 1767 1768 1769 function makeDeleteObject(type, objectToDelete){ 1770 if(type !== "Occurrence" && type !== "Name" && type !== "Variant" 1771 && type !== "Topic" && type !== "Association"){ 1772 throw "From makeDeleteObject(): type must be: \"Occurrence\" || \"Name\" " + 1773 "|| \"Variant\" || \"Topic\" || \"Association\" but is " + type; 1774 } 1775 if (!objectToDelete){ 1776 throw "From makeDeleteObject(): objectToDelete must be set"; 1777 } 1778 1779 var parentTopic = "null"; 1780 if(type === "Occurrence" || type === "Name"){ 1781 var psiFrame = objectToDelete.getFrame().parentNode.parentNode.parentNode.parentNode.select("tr." + CLASSES.subjectIdentifierFrame())[0]; 1782 var psiFields = psiFrame.select("input"); 1783 for(i = 0; psiFields && i !== psiFields.length; ++i){ 1784 var psiValue = psiFields[i].value; 1785 if(psiValue.strip().length !== 0){ 1786 parentTopic = psiValue.strip().toJSON(); 1787 break; 1788 } 1789 } 1790 } 1791 1792 var topics = "null"; 1793 if (type === "Topic"){ 1794 var psiFrame = objectToDelete.getFrame().select("tr." + CLASSES.subjectIdentifierFrame())[0]; 1795 var psiFields = psiFrame.select("input"); 1796 for(i = 0; psiFields && i !== psiFields.length; ++i){ 1797 var psiValue = psiFields[i].value; 1798 if(psiValue.strip().length !== 0){ 1799 topics = new Array(psiValue.strip()).toJSON(); 1800 break; 1801 } 1802 } 1803 } 1804 1805 var deletedObjects = null; 1806 if(type === "Topic"){ deletedObjects = topics; } 1807 else { deletedObjects = "[" + objectToDelete.toJSON() + "]"; } 1808 1809 var jsonData = "{\"type\":\"" + type + "\"," + 1810 "\"topics\":" + topics + "," + 1811 "\"associations\":" + "null" + "," + 1812 "\"parentTopic\":" + parentTopic + "," + 1813 "\"parentName\":" + "null" + "," + 1814 "\"names\":" + (type === "Name" ? deletedObjects : "null") + "," + 1815 "\"variants\":" + "null" + "," + 1816 "\"occurrences\":" + (type === "Occurrence" ? deletedObjects : "null") + "," + 1817 "\"parentAssociation\":" + "null" + "," + 1818 "\"roles\":" + "null" + "}"; 1819 1820 commitDeletedObject(jsonData, function(xhr){ 1821 alert("Objected deleted"); 1822 if(type === "Topic"){ 1823 $(CLASSES.subPage()).update(); 1824 makeHome(); 1825 } 1826 else if (type === "Occurrence" || type === "Name"){ 1827 if(objectToDelete.__owner__.__frames__.length > objectToDelete.__max__ 1828 && objectToDelete.__owner__.__frames__.length > 1){ 1829 objectToDelete.remove(); 1830 } 1831 else { 1832 if(type === "Occurrence"){ objectToDelete.__value__.setValue(""); } 1833 else { objectToDelete.__value__.__frames__[0].__content__.setValue(""); } 1834 } 1835 } 1836 }); 1837 1838 } 1839 1745 1840 // --- represenation of an occurrence element 1746 1841 var OccurrenceC = Class.create(ContainerC, {"initialize" : function($super, contents, occurrenceTypes, constraint, uniqueConstraints, owner, min, max, cssTitle, dblClickHandler){ … … 1827 1922 }); 1828 1923 } 1924 var myself = this; 1925 this.__table__.insert({"bottom" : makeRemoveLink(function(event){ 1926 makeDeleteObject("Occurrence", myself); 1927 }, "delete Occurrence")}); 1829 1928 } 1830 1929 catch(err){ … … 1895 1994 this.getFrame().select("tr." + CLASSES.valueFrame())[0].hide(); 1896 1995 this.getFrame().select("tr." + CLASSES.datatypeFrame())[0].hide(); 1996 this.getFrame().select("tr." + CLASSES.removeOccurrenceRow())[0].hide(); 1897 1997 this.__isMinimized__ = true; 1898 1998 } … … 1904 2004 this.getFrame().select("tr." + CLASSES.valueFrame())[0].show(); 1905 2005 this.getFrame().select("tr." + CLASSES.datatypeFrame())[0].show(); 2006 if(this.__disabled__ === false){ 2007 this.getFrame().select("tr." + CLASSES.removeOccurrenceRow())[0].show(); 2008 } 1906 2009 this.__isMinimized__ = false; 1907 2010 } … … 1917 2020 this.getFrame().writeAttribute({"title" : this.__cssTitle__}); 1918 2021 this.hideAddButton(); 2022 this.getFrame().select("tr." + CLASSES.removeOccurrenceRow())[0].hide(); 1919 2023 this.__disabled__ = true; 1920 2024 }, … … 1929 2033 this.getFrame().removeAttribute("title"); 1930 2034 checkRemoveAddButtons(this.__owner__, 1, this.__max__, this); 2035 this.getFrame().select("tr." + CLASSES.removeOccurrenceRow())[0].show(); 1931 2036 this.__disabled__ = false; 1932 2037 }}); … … 2223 2328 this.__occurrence__ = new OccurrenceContainerC(occurrencesContent, _constraints); 2224 2329 this.__table__.insert({"bottom" : newRow(CLASSES.occurrenceContainer(), "Occurrences", this.__occurrence__.getFrame())}); 2330 2331 var myself = this; 2332 this.__table__.insert({"bottom" : makeRemoveLink(function(event){ 2333 makeDeleteObject("Topic", myself); 2334 }, "delete Topic")}); 2225 2335 }catch(err){ 2226 2336 alert("From TopciC(): " + err); … … 2262 2372 this.getFrame().select("tr." + CLASSES.subjectIdentifierFrame())[0], 2263 2373 this.getFrame().select("tr." + CLASSES.nameContainer())[0], 2264 this.getFrame().select("tr." + CLASSES.occurrenceContainer())[0]); 2374 this.getFrame().select("tr." + CLASSES.occurrenceContainer())[0], 2375 this.getFrame().select("tr." + CLASSES.removeTopicRow())[0]); 2265 2376 for(var i = 0; i != rows.length; ++i){ 2266 2377 if(this.__minimized__ === false) rows[i].hide(); -
TabularUnified trunk/src/ajax/javascripts/requests.js ¶
r84 r279 220 220 221 221 222 // --- Sends a POST-Message to the server. The sent message enables the server 223 // --- to find the spcified object and mark it as deleted 224 function commitDeletedObject(json, onSuccessHandler, onFailureHandler) 225 { 226 if(!json || !onSuccessHandler) throw "From commitDeletedObject(): json and onSuccessHandler must be set!"; 227 try{ 228 var onFailure = onFailureHandler ? onFailureHandler : defaultFailureHandler; 229 var timeFun = setAjaxTimeout(TIMEOUT, COMMIT_URL); 230 231 new Ajax.Request(MARK_AS_DELETED_URL, { 232 "method" : "post", 233 "postBody" : json, 234 "onSuccess" : createXHRHandler(onSuccessHandler, timeFun), 235 "onFailure" : createXHRHandler(onFailure, timeFun)}); 236 } 237 catch(err){ 238 alert("From commitDeletedObject(): " + err); 239 } 240 } 241 242 222 243 // --- Requests a JSON-Fragment for the passed psi and calls the onSuccessHandler function 223 244 // --- after a succeeded request. -
TabularUnified trunk/src/json/json_exporter.lisp ¶
r27 r279 9 9 10 10 (defpackage :json-exporter 11 (:use :cl :json :datamodel )11 (:use :cl :json :datamodel :json-tmcl-constants) 12 12 (:export :to-json-string 13 13 :get-all-topic-psis … … 299 299 (when psi-list 300 300 (map 'list #'uri psi-list))) 301 (map 'list #'psis (elephant:get-instances-by-class 'TopicC)))))) 301 (json-tmcl::clean-topics 302 (elephant:get-instances-by-class 'TopicC)))))) 302 303 303 304 … … 352 353 (concatenate 'string "[" json-string "]")) 353 354 "null")) 355 356 357 (defun clean-topics(isas-or-akos) 358 (remove-if 359 #'null 360 (map 'list 361 #'(lambda(top) 362 (when (d:find-item-by-revision top 0) 363 top)) 364 isas-or-akos))) -
TabularUnified trunk/src/json/json_importer.lisp ¶
r229 r279 363 363 (t 364 364 (error "json-importer:get-fragment-values-from-json-string: 365 bad item-specifier found in json-list "))))365 bad item-specifier found in json-list (~a)" (car j-elem))))) 366 366 (unless topic 367 367 (error "json-importer:get-fragment-values-from-json-string: the element topic must be set")) -
TabularUnified trunk/src/json/json_tmcl.lisp ¶
r277 r279 180 180 (declare (list names) (string parent-psi) (integer revision)) 181 181 (let ((parent-topic (d:get-item-by-psi parent-psi)) 182 (err "From delete-name -from-json(): "))182 (err "From delete-names-from-json(): ")) 183 183 (unless parent-topic 184 184 (error "~a~a not found" … … 236 236 (declare (list occurrences) (string parent-psi) (integer revision)) 237 237 (let ((parent-topic (d:get-item-by-psi parent-psi)) 238 (err "From delete-occurrence -from-json(): "))238 (err "From delete-occurrences-from-json(): ")) 239 239 (unless parent-topic 240 240 (error "~a~a not found" err parent-psi)) … … 285 285 (dolist (j-assoc associations) 286 286 (let ((plist (json-importer::get-association-values-from-json-list j-assoc)) 287 (err "From delete-association -from-json(): "))287 (err "From delete-associations-from-json(): ")) 288 288 (let ((assoc (find-association-from-json plist))) 289 289 (unless assoc … … 298 298 (let ((psi (elephant:get-instance-by-value 'd:PersistentIdC 'd:uri uri))) 299 299 (unless psi 300 (error "From delete-topic -from-json(): PSI ~a not found" uri))300 (error "From delete-topics-from-json(): PSI ~a not found" uri)) 301 301 (pushnew psi psis))) 302 302 (let ((tops … … 1574 1574 (get-direct-subtypes-of-topic topic-instance))))))) 1575 1575 (let ((cleaned-isas ;;all constraint topics are removed 1576 (remove-if #'null (map 'list #'(lambda(top-entry) 1577 (when (find-if #'(lambda(psi) 1578 (unless (or (string= (uri psi) *constraint-psi*) 1579 (string= (uri psi) *occurrencetype-psi*) 1580 (string= (uri psi) *nametype-psi*) 1581 (string= (uri psi) *associationtype-psi*) 1582 (string= (uri psi) *roletype-psi*) 1583 (string= (uri psi) *scopetype-psi*) 1584 (string= (uri psi) *schema-psi*)) 1585 top-entry)) 1586 (psis (getf top-entry :topic))) 1587 top-entry)) 1588 isas-of-this))) 1576 (clean-topic-entries isas-of-this)) 1589 1577 (cleaned-akos ;;all constraint topics are removed 1590 (remove-if #'null (map 'list #'(lambda(top-entry) 1591 (when (find-if #'(lambda(psi) 1592 (unless (or (string= (uri psi) *constraint-psi*) 1593 (string= (uri psi) *occurrencetype-psi*) 1594 (string= (uri psi) *nametype-psi*) 1595 (string= (uri psi) *associationtype-psi*) 1596 (string= (uri psi) *roletype-psi*) 1597 (string= (uri psi) *scopetype-psi*) 1598 (string= (uri psi) *schema-psi*)) 1599 top-entry)) 1600 (psis (getf top-entry :topic))) 1601 top-entry)) 1602 akos-of-this)))) 1578 (clean-topic-entries akos-of-this))) 1603 1579 (list :topic topic-instance 1604 1580 :is-type is-type … … 1611 1587 cleaned-akos)))))) 1612 1588 1589 (defun clean-topic-entries(isas-or-akos) 1590 (remove-if 1591 #'null 1592 (map 'list 1593 #'(lambda(top-entry) 1594 (when (and (d:find-item-by-revision (getf top-entry :topic) 0) 1595 (find-if 1596 #'(lambda(psi) 1597 (unless (or (string= (uri psi) *constraint-psi*) 1598 (string= (uri psi) *occurrencetype-psi*) 1599 (string= (uri psi) *nametype-psi*) 1600 (string= (uri psi) *associationtype-psi*) 1601 (string= (uri psi) *roletype-psi*) 1602 (string= (uri psi) *scopetype-psi*) 1603 (string= (uri psi) *schema-psi*)) 1604 top-entry)) 1605 (psis (getf top-entry :topic)))) 1606 top-entry)) 1607 isas-or-akos))) 1608 1613 1609 1614 1610 (defun get-all-tree-roots () … … 1616 1612 of any other topic." 1617 1613 (let ((all-topics 1618 (elephant:get-instances-by-class 'd:TopicC))) 1614 (remove-if #'null 1615 (map 'list 1616 #'(lambda(top) 1617 (when (d:find-item-by-revision top 0) 1618 top)) 1619 (elephant:get-instances-by-class 'd:TopicC))))) 1619 1620 (remove-if #'null 1620 1621 (map 'list #'(lambda(x) -
TabularUnified trunk/src/json/json_tmcl_validation.lisp ¶
r85 r279 376 376 "Returns all topics that are valid tmcl-types" 377 377 (let ((all-topics 378 (elephant:get-instances-by-class 'd:TopicC)) 378 (json-exporter::clean-topics 379 (elephant:get-instances-by-class 'd:TopicC))) 379 380 (topictype (get-item-by-psi json-tmcl-constants::*topictype-psi*)) 380 381 (topictype-constraint (is-type-constrained))) … … 400 401 type-instance or supertype-subtype." 401 402 (let ((all-topics 402 (elephant:get-instances-by-class 'd:TopicC))) 403 (json-exporter::clean-topics 404 (elephant:get-instances-by-class 'd:TopicC)))) 403 405 (let ((valid-instances 404 406 (remove-if #'null -
TabularUnified trunk/src/rest_interface/set-up-json-interface.lisp ¶
r275 r279 116 116 hunchentoot:*dispatch-table*) 117 117 (push 118 (create-regex-dispatcher mark-as-deleted-url #'mark-as-deleted )118 (create-regex-dispatcher mark-as-deleted-url #'mark-as-deleted-handler) 119 119 hunchentoot:*dispatch-table*)) 120 120 … … 303 303 (handler-case (with-reader-lock 304 304 (let ((topics 305 (elephant:get-instances-by-class 'd:TopicC))) 305 (remove-if 306 #'null 307 (map 'list #'(lambda(top) 308 (when (d:find-item-by-revision top 0) 309 top)) 310 (elephant:get-instances-by-class 'd:TopicC))))) 306 311 (let ((end 307 312 (cond … … 373 378 (setf (hunchentoot:return-code*) hunchentoot:+http-bad-request+)))) 374 379 380 375 381 ;; ============================================================================= 376 382 ;; --- some helper functions ---------------------------------------------------
Note: See TracChangeset
for help on using the changeset viewer.