From ebd55a434236c156afb6a13b85ec11f103c859e5 Mon Sep 17 00:00:00 2001
From: sufwan khalid
Date: Mon, 12 Aug 2024 11:37:28 +0500
Subject: [PATCH 1/2] added owner flag in bulk import
---
.../webapp/appadmin/resendBulkImportID.jsp | 15 +-
src/main/webapp/import.jsp | 229 +++++++++++++++++-
2 files changed, 233 insertions(+), 11 deletions(-)
diff --git a/src/main/webapp/appadmin/resendBulkImportID.jsp b/src/main/webapp/appadmin/resendBulkImportID.jsp
index 4a372ebca0..0dd0378694 100644
--- a/src/main/webapp/appadmin/resendBulkImportID.jsp
+++ b/src/main/webapp/appadmin/resendBulkImportID.jsp
@@ -6,13 +6,11 @@ org.ecocean.grid.*,
org.ecocean.cache.*,org.ecocean.ia.*,
org.json.*,org.ecocean.servlet.importer.ImportTask,org.ecocean.identity.IBEISIA,
java.io.*,java.util.*, java.io.FileInputStream, java.io.File, java.io.FileNotFoundException, org.ecocean.*,org.ecocean.servlet.*,javax.jdo.*, java.lang.StringBuffer, java.util.Vector, java.util.Iterator, java.lang.NumberFormatException"%>
-
<%
response.setContentType("application/json");
response.setCharacterEncoding("UTF-8");
response.setHeader("Access-Control-Allow-Origin", "*");
-
System.out.println("==> In ImporIA Servlet ");
String context= ServletUtilities.getContext(request);
@@ -25,12 +23,17 @@ JSONObject res = new JSONObject();
//String queryEncounterId = null;
String importIdTask = request.getParameter("importIdTask");
-List locationIDs = new ArrayList();
+List locationIDs = new ArrayList();
+String ownerFilter = "";
if(request.getParameterValues("locationID")!=null) {
String[] vals=request.getParameterValues("locationID");
locationIDs = Arrays.asList(vals);
}
+if(request.getParameter("owner")!=null) {
+ ownerFilter=request.getParameter("owner");
+}
+
try {
res.put("success","false");
@@ -55,6 +58,12 @@ try {
//matchingSetFilter = { locationIds: locationIds }
if(locationIDs!=null && locationIDs.size()>0)mf.put("locationIds",locationIDs);
//mf.put("projectId", project.getId());
+
+ if (!ownerFilter.isEmpty()) {
+ mf.put("owner", ownerFilter);
+ }
+
+
taskParameters.put("matchingSetFilter", mf);
diff --git a/src/main/webapp/import.jsp b/src/main/webapp/import.jsp
index 0ea4e1c887..e509daf9c9 100644
--- a/src/main/webapp/import.jsp
+++ b/src/main/webapp/import.jsp
@@ -280,6 +280,62 @@ a.button:hover {
background-color: #DDA;
text-decoration: none;
}
+
+.ia-match-filter-dialog .option-cols {
+ -webkit-column-count: 1;
+ -moz-column-count: 1;
+ column-count: 1;
+}
+.ia-match-filter-dialog .option-cols input {
+ vertical-align: top;
+}
+.ia-match-filter-dialog .option-cols .item {
+ padding: 1px 4px;
+ border-radius: 5px;
+}
+.ia-match-filter-dialog .option-cols .item:hover {
+ background-color: #AAA;
+}
+.ia-match-filter-dialog .option-cols .item label {
+ font-size: 0.9em;
+ width: 90%;
+ margin-left: 5px;
+ line-height: 1.0em;
+}
+.ia-match-filter-dialog .option-cols .item-checked label {
+ font-weight: bold;
+}
+.ia-match-filter-dialog ul {
+ list-style-type: none;
+}
+.ia-match-filter-dialog .item-count {
+ font-size: 0.8em;
+ color: #777;
+ margin-left: 9px;
+}
+.ia-match-filter-section {
+ margin-top: 10px;
+ border-top: solid 3px #999;
+}
+.ia-match-filter-title {
+ margin: 20px 0 5px 0;
+ padding: 1px 0 1px 20px;
+ background-color: #b491c8;
+ color: #555;
+ font-weight: bold;
+}
+.ia-match-filter-dialog {
+ display: none;
+ z-index: 3000;
+ position: fixed;
+ top: 10%;
+ width: 80%;
+ padding: 15px;
+ border: solid 5px #888;
+ background-color: #fff;
+}
+
+
@@ -302,6 +358,8 @@ String context = ServletUtilities.getContext(request);
Shepherd myShepherd = new Shepherd(context);
myShepherd.setAction("import.jsp");
myShepherd.beginDBTransaction();
+String langCode = ServletUtilities.getLanguageCode(request);
+Properties encprops = ShepherdProperties.getOrgProperties("encounter.properties", langCode, context, request, myShepherd);
//should the user see the detect and/or detect+ID buttons?
boolean allowIA=false;
@@ -437,8 +495,10 @@ try{
int numMatchAgainst=0;
boolean foundChildren = false;
int numMatchTasks=0;
-
- HashMap jarrs = new HashMap();
+
+
+
+ HashMap jarrs = new HashMap();
if (Util.collectionSize(itask.getEncounters()) > 0) {
for (Encounter enc : itask.getEncounters()) {
@@ -600,7 +660,10 @@ try{
jarrs.put(enc.getCatalogNumber(), jarr);
}
- int percent = -1;
+
+
+
+ int percent = -1;
if (allAssets.size() > 1) percent = Math.round(numIA / allAssets.size() * 100);
%>
@@ -802,6 +865,11 @@ try{
};
for (let [encId, maIds] of js_jarrs) { data.bulkImport[encId] = maIds; } // convert js_jarrs map into js object
if (!skipIdent && locationIds && (locationIds.indexOf('') < 0)) data.taskParameters.matchingSetFilter = { locationIds: locationIds };
+
+ if ($('#match-filter-owner-me').is(':checked')){
+ if(!data.taskParameters.matchingSetFilter) data.taskParameters.matchingSetFilter = {};
+ data.taskParameters.matchingSetFilter["owner"] = ["me"]
+ }
console.log('sendToIA() SENDING: locationIds=%o data=%o', locationIds, data);
$.ajax({
@@ -826,6 +894,7 @@ try{
$('#ia-send-div').hide().after('sending... please wait
');
//var locationIds = $('#id-locationids').val();
var locationIds = '';
+ var owner = '';
$("#id-locationids option:selected").each(function(){
locationIds+='&locationID='+this.value;
});
@@ -833,9 +902,13 @@ try{
//if (locationIds && (locationIds.indexOf('') < 0)) data.taskParameters.matchingSetFilter = { locationIds: locationIds };
console.log('resendToID() SENDING: locationIds=%o', locationIds);
+
+ if ($('#match-filter-owner-me').is(':checked')){
+ owner = "&owner=" + encodeURIComponent(JSON.stringify(["me"]));
+ }
$.ajax({
- url: wildbookGlobals.baseUrl + '/appadmin/resendBulkImportID.jsp?importIdTask=<%=taskId%>'+locationIds,
+ url: wildbookGlobals.baseUrl + '/appadmin/resendBulkImportID.jsp?importIdTask=<%=taskId%>'+locationIds + owner,
dataType: 'json',
type: 'GET',
contentType: 'application/javascript',
@@ -850,6 +923,33 @@ try{
});
}
+
+ function shouldselectAllOptions(shouldselect){
+ $("#id-locationids option").each(function(index,option){
+ if(option.value){
+ option.selected = shouldselect;
+ }
+
+ });
+ }
+
+ function selectLocationbyName(location){
+ if (location){
+
+ $("#id-locationids option").each(function(index,option){
+ if(option.value === location){
+ option.selected = true;
+ }
+
+ });
+
+ }
+ }
+
+ function showModal(){
+
+ $('.ia-match-filter-dialog').show()
+ }
@@ -875,7 +975,7 @@ try{
%>
-
+
<%
@@ -889,9 +989,8 @@ try{
if (allowReID) {
%>
-
-
Send to identification matching against
location(s):
- <%=LocationID.getHTMLSelector(true, locationIds, null, "id-locationids", "locationID", "") %>
+
<%
@@ -910,6 +1009,112 @@ try{
+
+
+
+
+
<%
}
%>
@@ -930,8 +1135,16 @@ finally{
myShepherd.rollbackDBTransaction();
myShepherd.closeDBTransaction();
}
+
+
+
%>
+
+
+
+
+
From 8b8fef7f4c47494e3f2a6c761aae11148f344fd2 Mon Sep 17 00:00:00 2001
From: sufwan khalid
Date: Mon, 12 Aug 2024 11:42:48 +0500
Subject: [PATCH 2/2] removed unnecessary changes
---
.../webapp/appadmin/resendBulkImportID.jsp | 5 ++--
src/main/webapp/import.jsp | 30 ++-----------------
2 files changed, 4 insertions(+), 31 deletions(-)
diff --git a/src/main/webapp/appadmin/resendBulkImportID.jsp b/src/main/webapp/appadmin/resendBulkImportID.jsp
index 0dd0378694..cd4762b607 100644
--- a/src/main/webapp/appadmin/resendBulkImportID.jsp
+++ b/src/main/webapp/appadmin/resendBulkImportID.jsp
@@ -6,11 +6,13 @@ org.ecocean.grid.*,
org.ecocean.cache.*,org.ecocean.ia.*,
org.json.*,org.ecocean.servlet.importer.ImportTask,org.ecocean.identity.IBEISIA,
java.io.*,java.util.*, java.io.FileInputStream, java.io.File, java.io.FileNotFoundException, org.ecocean.*,org.ecocean.servlet.*,javax.jdo.*, java.lang.StringBuffer, java.util.Vector, java.util.Iterator, java.lang.NumberFormatException"%>
+
<%
response.setContentType("application/json");
response.setCharacterEncoding("UTF-8");
response.setHeader("Access-Control-Allow-Origin", "*");
+
System.out.println("==> In ImporIA Servlet ");
String context= ServletUtilities.getContext(request);
@@ -58,12 +60,9 @@ try {
//matchingSetFilter = { locationIds: locationIds }
if(locationIDs!=null && locationIDs.size()>0)mf.put("locationIds",locationIDs);
//mf.put("projectId", project.getId());
-
if (!ownerFilter.isEmpty()) {
mf.put("owner", ownerFilter);
}
-
-
taskParameters.put("matchingSetFilter", mf);
diff --git a/src/main/webapp/import.jsp b/src/main/webapp/import.jsp
index e509daf9c9..f5cfec2c2f 100644
--- a/src/main/webapp/import.jsp
+++ b/src/main/webapp/import.jsp
@@ -496,9 +496,7 @@ try{
boolean foundChildren = false;
int numMatchTasks=0;
-
-
- HashMap jarrs = new HashMap();
+ HashMap jarrs = new HashMap();
if (Util.collectionSize(itask.getEncounters()) > 0) {
for (Encounter enc : itask.getEncounters()) {
@@ -660,10 +658,7 @@ try{
jarrs.put(enc.getCatalogNumber(), jarr);
}
-
-
-
- int percent = -1;
+ int percent = -1;
if (allAssets.size() > 1) percent = Math.round(numIA / allAssets.size() * 100);
%>
@@ -902,7 +897,6 @@ try{
//if (locationIds && (locationIds.indexOf('') < 0)) data.taskParameters.matchingSetFilter = { locationIds: locationIds };
console.log('resendToID() SENDING: locationIds=%o', locationIds);
-
if ($('#match-filter-owner-me').is(':checked')){
owner = "&owner=" + encodeURIComponent(JSON.stringify(["me"]));
}
@@ -933,19 +927,6 @@ try{
});
}
- function selectLocationbyName(location){
- if (location){
-
- $("#id-locationids option").each(function(index,option){
- if(option.value === location){
- option.selected = true;
- }
-
- });
-
- }
- }
-
function showModal(){
$('.ia-match-filter-dialog').show()
@@ -1135,16 +1116,9 @@ finally{
myShepherd.rollbackDBTransaction();
myShepherd.closeDBTransaction();
}
-
-
-
%>
-
-
-
-