Example #1
0
exports.editConceptDocuments = function(res, docId, op, concept, store) {
  var ii = 0;
  if(op !== "add" && op !== "del") {
    res.setStatusCode(400);
    res.send("Invalid operation: " + op);
    return;
  }
  var docStore = stores.getDocStore(store);
  var doc = stores.requireRecord(res, docStore, "document", docId);

  // perform operation
  if(op === "add") {
    concept.addJoin("docs", doc);
  }
  else if(op === "del") {
    concept.delJoin("docs", doc);
  }
  else {
    res.setStatusCode(500);
    res.send("Operation not properly matched.");
    return;
  }
  var now = new Date();
  concept.modified = now.toISOString();
  store.add(concept);

  var rSet = concept.docs; // concept documents
  var docs = [];
  for(ii = 0; ii < rSet.length; ii++) {
    docs.push(rSet[ii].$id);
  }
  res.send(docs); 
};
Example #2
0
               function (req, res) {
  console.say("elycite API - Document <did> GET");
  var params = restf.requireParams(req, res, "store", "rid");
  if(params === null) { return; }
  var store = stores.requireExists(res, params.store);
  if(store === null) { return; }
  var recId = restf.requireInt(res, "rid", params.rid);
  if(recId === null) { return; }
  var rec = stores.requireRecord(res, store, "record", recId);
  if(rec == null) { return; }
  res.send(rec.toJSON());
});
Example #3
0
               function (req, res) {
  console.say("elycite API - Concept GET docs");
  var params = restf.requireParams(req, res, "ontology", "cid");
  if(params === null) { return; }
  var store = stores.requireExists(res, params.ontology);
  if(store === null) { return; }
  var conceptId = restf.requireInt(res, "conceptId", params.cid);
  if(conceptId === null) { return; }
  var concept = stores.requireRecord(res, store, "concept", conceptId);
  if(concept === null) { return; }

  concepts.getConceptDocuments(req, res, concept, store);
});
Example #4
0
               function (req, res) {
  console.say("elycite API - Concept GET suggestions");
  var params = restf.requireParams(req, res, "ontology", "cid");
  if(params === null) { return; }
  var store = stores.requireExists(res, params.ontology);
  if(store === null) { return; }
  var conceptId = restf.requireInt(res, "conceptId", params.cid);
  if(conceptId === null) { return; }
  var concept = stores.requireRecord(res, store, "concept", conceptId);
  if(concept === null) { return; }
  concept = restf.requireNotDeleted(concept, "concept");
  if(concept === null) { return; }

  concepts.getConceptSuggestionsByClustering(req, res, concept, store);
});
Example #5
0
               function (req, res) {
  console.say("elycite API - Concept edit PUT");
  var params = restf.requireParams(req, res, "ontology", "cid");
  if(params === null) { return; }
  var store = stores.requireExists(res, params.ontology);
  if(store === null) { return; }
  var data = restf.requireJSON(req, res);
  if(data === null) { return; }
  var conceptId = restf.requireInt(res, "cid", params.cid);
  if(conceptId === null) { return; }
  var concept = stores.requireRecord(res, store, "concept", conceptId);
  if(concept === null) { return; }

  concepts.editConcept(res, concept, data, store, params.ontology);
});
Example #6
0
               function (req, res) {
  console.say("elycite API - Concept Classifier - POST");
  var params = restf.requireParams(req, res, "ontology");
  if(params === null) { return; }
  var store = stores.requireExists(res, params.ontology);
  if(store === null) { return; }
  var data = restf.requireJSON(req, res, "name", "cid");
  var conceptId = restf.requireInt(res, "conceptId", data.cid);
  if(conceptId === null) { return; }
  var concept = stores.requireRecord(res, store, "concept", conceptId);
  if(concept === null) { return; }
  concept = restf.requireNotDeleted(concept, "concept");
  if(concept === null) { return; }

  cls.create(res, data, concept, store, params.ontology);
});
Example #7
0
               "POST", function (req, res) {
  console.say("elycite API - AL/name/ POST");
  var params = restf.requireParams(req, res, "ontology", "cid", "alid");
  if(params === null) { return; }
  var store = stores.requireExists(res, params.ontology);
  if(store === null) { return; }
  var conceptId = restf.requireInt(res, "conceptId", params.cid);
  if(conceptId === null) { return; }
  var concept = stores.requireRecord(res, store, "concept", conceptId);
  if(concept === null) { return; }
  concept = restf.requireNotDeleted(concept, "concept");
  if(concept === null) { return; }
  var name = params.alid;
 
  al.finish(res, name, concept);
});
Example #8
0
               function (req, res) {
  console.say("elycite API - Concept/suggeskeywords");
  var params = restf.requireParams(req, res, "ontology", "cid");
  if(params === null) { return; }
  var store = stores.requireExists(res, params.ontology);
  if(store === null) { return; }
  var conceptId = restf.requireInt(res, "conceptId", params.cid);
  if(conceptId === null) { return; }
  var concept = stores.requireRecord(res, store, "concept", conceptId);
  if(concept === null) { return; }
  concept = restf.requireNotDeleted(concept, "concept");
  if(concept === null) { return; }

  var args = req.args || {};
  concepts.getKeywordSuggestions(res, args, concept);
});
Example #9
0
               function (req, res) {
  console.say("elycite API - Concept/Search");
  var params = restf.requireParams(req, res, "ontology", "cid");
  if(params === null) { return; }
  var store = stores.requireExists(res, params.ontology);
  if(store === null) { return; }
  var conceptId = restf.requireInt(res, "conceptId", params.cid);
  if(conceptId === null) { return; }
  var concept = stores.requireRecord(res, store, "concept", conceptId);
  if(concept === null) { return; }
  concept = restf.requireNotDeleted(concept, "concept");
  if(concept === null) { return; }
  var args = restf.requireArgs(req, res, "query");
  if(args === null) { return; }

  concepts.getConceptSuggestionFromQuery(res, concept, store, args.query);
});
Example #10
0
               function (req, res) {
  console.say("elycite API - GET SUB CONCETPS FROM CLASSIFIER");
  var params = restf.requireParams(req, res, "ontology", "cid", "mid");
  if(params === null) { return; }
  var store = stores.requireExists(res, params.ontology);
  if(store === null) { return; }
  var conceptId = restf.requireInt(res, "conceptId", params.cid);
  if(conceptId === null) { return; }
  var concept = stores.requireRecord(res, store, "concept", conceptId);
  if(concept === null) { return; }
  concept = restf.requireNotDeleted(concept, "concept");
  if(concept === null) { return; }
  var args = req.args || {};
  var threshold = restf.optionalFloat(args, "thresh", 0);
  var mid = params.mid;

  cls.subConcepts(res, mid, threshold, concept, store);
});
Example #11
0
               function (req, res) {
  console.say("elycite API - AL/name/ PATCH");
  var params = restf.requireParams(req, res, "ontology", "cid", "alid");
  if(params === null) { return; }
  var store = stores.requireExists(res, params.ontology);
  if(store === null) { return; }
  var conceptId = restf.requireInt(res, "conceptId", params.cid);
  if(conceptId === null) { return; }
  var concept = stores.requireRecord(res, store, "concept", conceptId);
  if(concept === null) { return; }
  concept = restf.requireNotDeleted(concept, "concept");
  if(concept === null) { return; }
  var data = restf.requireJSON(req, res, "answer", "did");
  var did = restf.requireInt(res, "did", data.did); // actually did
  var name = params.alid;

  al.answerQuestion(res, name, concept, params.ontology, did, data.answer);
});
Example #12
0
               function (req, res) {
  console.say("elycite API - AL Create - POST");
  var params = restf.requireParams(req, res, "ontology", "cid");
  if(params === null) { return; }
  var store = stores.requireExists(res, params.ontology);
  if(store === null) { return; }
  var conceptId = restf.requireInt(res, "conceptId", params.cid);
  if(conceptId === null) { return; }
  var concept = stores.requireRecord(res, store, "concept", conceptId);
  if(concept === null) { return; }
  concept = restf.requireNotDeleted(res, concept, "concept");
  if(concept === null) { return; }
  var data = restf.requireJSON(req, res, "query", "fieldName");
  var query = data.query;
  var fieldName = data.fieldName;

  al.create(res, data, concept, store, query, fieldName);
});
Example #13
0
               function (req, res) {
  console.say("elycite API - Concept/Query");
  var params = restf.requireParams(req, res, "ontology", "cid");
  if(params === null) { return; }
  var store = stores.requireExists(res, params.ontology);
  if(store === null) { return; }
  var conceptId = restf.requireInt(res, "conceptId", params.cid);
  if(conceptId === null) { return; }
  var concept = stores.requireRecord(res, store, "concept", conceptId);
  if(concept === null) { return; }
  concept = restf.requireNotDeleted(res, concept, "concept");
  if(concept === null) { return; }
  var args = restf.requireArgs(req, res, "docIds");
  if(args === null) { return; }

  //concepts.getConceptDocsFromSearch(res, concept, store, args.docIds, params); 
  documents.getSpecificDocuments(res, store, params.ontology, args.docIds)
});
Example #14
0
               function (req, res) {
  console.say("elycite API - Concept Edit doc list");
  var params = restf.requireParams(req, res, "ontology", "cid");
  if(params === null) { return; }
  var store = stores.requireExists(res, params.ontology);
  if(store === null) { return; }
  var conceptId = restf.requireInt(res, "conceptId", params.cid);
  if(conceptId === null) { return; }
  var concept = stores.requireRecord(res, store, "concept", conceptId);
  if(concept === null) { return; }
  concept = restf.requireNotDeleted(concept, "concept");
  if(concept === null) { return; }
  var data = restf.requireJSON(req, res, "operation", "docId");
  if(data === null) { return; }
  var docId = restf.requireInt(res, "docId", data.docId);
  if(docId === null) { return; }

  concepts.editConceptDocuments(res, docId, data.operation, concept, store);
});