Skip to content

Commit

Permalink
fixing radio buttons ui for DOR (#6)
Browse files Browse the repository at this point in the history
 fixing radio buttons ui for DOR and updating types comments
  • Loading branch information
valentin-gauthier-geosiris authored Dec 2, 2022
1 parent 255ff9d commit 3c60a3e
Show file tree
Hide file tree
Showing 24 changed files with 2,973 additions and 4,886 deletions.
340 changes: 24 additions & 316 deletions docker/data/comments/common2_0.json

Large diffs are not rendered by default.

689 changes: 88 additions & 601 deletions docker/data/comments/common2_1.json

Large diffs are not rendered by default.

694 changes: 89 additions & 605 deletions docker/data/comments/common2_2.json

Large diffs are not rendered by default.

876 changes: 149 additions & 727 deletions docker/data/comments/common2_3.json

Large diffs are not rendered by default.

1,170 changes: 584 additions & 586 deletions docker/data/comments/prodml2_2.json

Large diffs are not rendered by default.

569 changes: 279 additions & 290 deletions docker/data/comments/resqml2_0_1.json

Large diffs are not rendered by default.

475 changes: 236 additions & 239 deletions docker/data/comments/resqml2_2.json

Large diffs are not rendered by default.

509 changes: 244 additions & 265 deletions docker/data/comments/resqml_dev3x_2_2.json

Large diffs are not rendered by default.

821 changes: 416 additions & 405 deletions docker/data/comments/witsml2_0.json

Large diffs are not rendered by default.

839 changes: 404 additions & 435 deletions docker/data/comments/witsml2_1.json

Large diffs are not rendered by default.

10 changes: 9 additions & 1 deletion docker/tomcat/web-no-ssl.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,13 @@
<listener>
<listener-class>com.geosiris.webstudio.servlet.global.SessionCounter</listener-class>
</listener>


<filter>
<filter-name>SameSiteFilter</filter-name>
<filter-class>com.geosiris.webstudio.filters.SameSiteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>SameSiteFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>com.geosiris</groupId>
<artifactId>webstudio</artifactId>
<name>${project.groupId}:${project.artifactId}</name>
<version>1.0.4</version>
<version>1.0.5</version>
<organization>
<name>Geosiris</name>
<url>http://www.geosiris.com</url>
Expand Down
56 changes: 56 additions & 0 deletions src/main/java/com/geosiris/webstudio/filters/SameSiteFilter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
Copyright 2019 GEOSIRIS
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package com.geosiris.webstudio.filters;

import java.io.IOException;
import java.util.Collection;

import jakarta.servlet.FilterChain;
import jakarta.servlet.FilterConfig;
import jakarta.servlet.ServletException;
import jakarta.servlet.ServletRequest;
import jakarta.servlet.ServletResponse;
import jakarta.servlet.http.HttpServletResponse;

public class SameSiteFilter implements jakarta.servlet.Filter {
@Override
public void init(FilterConfig filterConfig) throws ServletException {
}

@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
chain.doFilter(request, response);
addSameSiteAttribute((HttpServletResponse) response); // add SameSite=strict cookie attribute
}

private void addSameSiteAttribute(HttpServletResponse response) {
Collection<String> headers = response.getHeaders("Set-Cookie");
boolean firstHeader = true;
for (String header : headers) {
if (firstHeader) {
response.setHeader("Set-Cookie", String.format("%s; %s", header, "SameSite=Strict"));
firstHeader = false;
continue;
}
response.addHeader("Set-Cookie", String.format("%s; %s", header, "SameSite=Strict"));
}
}

@Override
public void destroy() {

}
}
55 changes: 0 additions & 55 deletions src/main/java/com/geosiris/webstudio/servlet/OSDU_Manifest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
import com.geosiris.webstudio.model.WorkspaceContent;
import com.geosiris.webstudio.utils.HttpSender;
import com.geosiris.webstudio.utils.SessionUtility;
import energyml.common2_3.Citation;
import energyml.resqml2_2.TriangulatedSetRepresentation;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
Expand Down Expand Up @@ -121,57 +119,4 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)
out.write(answer);
out.flush();
}

public static void main(String[] argv) throws IOException {
// File f = new File("C:/Users/Cryptaro/Downloads/java.epc");
// FileOutputStream fio = new FileOutputStream(f);

// try(ZipOutputStream epc = new ZipOutputStream(fio, StandardCharsets.UTF_8)) {
//// epc.setLevel(0);
// ZipEntry ze_resqml = new ZipEntry("test.xml");
// epc.putNextEntry(ze_resqml);
// epc.write("coucou".getBytes(StandardCharsets.UTF_8));
// epc.closeEntry();
//// epc.finish();
//// epc.flush();
// } catch (FileNotFoundException e) {
// throw new RuntimeException(e);
// }
// fio.close();

Map<String, String> otherParams = new HashMap<>();
otherParams.put("data_partition_id", "osdu");
otherParams.put("token", "ya29.a0Aa4xrXMgK0dBJo62n6NwsjUBvofohmy59DMtdpT7rrrewFDDIZOhNFmBUlmGpP33UUz7Y1QpWyq4p3SOj3KwXDgcWEQF7T0dHVAtpmNNTNhpWKim1JsA83s-ep50otqQHisE4uDjeLugnw78pNgYv0RzX_FEaCgYKATASARISFQEjDvL98VqQXGcQ1M5u1F7UTOQVxg0163");
otherParams.put("host", "https://community.gcp.gnrg-osdu.projects.epam.com/api/dataset/v1");

// HttpSender.sendfileWithPostRequest(null,
// (outputStream -> {
// try(ZipOutputStream epc = new ZipOutputStream(outputStream, StandardCharsets.UTF_8)) {
// // epc.setLevel(0);
// ZipEntry ze_resqml = new ZipEntry("test.xml");
// epc.putNextEntry(ze_resqml);
// epc.write("coucou".getBytes(StandardCharsets.UTF_8));
// epc.closeEntry();
// // epc.finish();
// // epc.flush();
// } catch (FileNotFoundException e) {
// throw new RuntimeException(e);
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
// }),
// "http://localhost:8000/", null, null, "file", otherParams);
WorkspaceContent wc = new WorkspaceContent();
TriangulatedSetRepresentation tr = new TriangulatedSetRepresentation();
String uuid = UUID.randomUUID()+"";
Citation cit = new Citation();
cit.setTitle("coucou");
tr.setUuid(uuid);
tr.setCitation(cit);
wc.getReadObjects().put(uuid, tr);
HttpSender.sendfileWithPostRequest(null,
(outputStream -> ExportEPCFile.exportEPCFile(outputStream, wc, ExportVersion.CLASSIC)),
"http://localhost:8000/", null, null, "file", otherParams);

}
}
97 changes: 56 additions & 41 deletions src/main/java/com/geosiris/webstudio/utils/ObjectTree.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import com.geosiris.energyml.utils.ObjectController;
import com.geosiris.energyml.utils.Pair;
import com.geosiris.webstudio.property.ConfigurationType;
import com.geosiris.webstudio.servlet.Editor;
import com.google.gson.Gson;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

Expand Down Expand Up @@ -92,34 +94,37 @@ public static ObjectTree createTree(String name, Object obj, Class<?> objClass,
simpleName.substring(0, 1).toLowerCase() + simpleName.substring(1));
}
ObjectTree tree = new ObjectTree(name, obj, objClass, parent, isMandatory);

if (!bypassNullObj && obj != null) {
List<Pair<Class<?>, String>> attributes = ObjectController.getClassAttributes(objClass);
if (List.class.isAssignableFrom(objClass)) {
// Si c'est une liste on va chercher les elements
int cpt = 0;
for (Object elt : (List) obj) {
// logger.error("LIST CONTENT ("+cpt+") " + elt);
// Non on ne test pas si c'est une propriete car c'est le contenu de la liste
// donc peut importe le type,
Class<?> eltClass = Object.class;
if (elt != null) {
eltClass = elt.getClass();
tree.appendChild(createTree(name + "." + cpt, elt, eltClass, tree, bypassNullObj));
cpt++;
} else {
try {
assert parent != null;
eltClass = (Class<?>) ObjectController.getClassTemplates(parent.getDataClass(),
name.substring(name.lastIndexOf(".") + 1)).getActualTypeArguments()[0];

logger.error("Trying to create with class : " + eltClass);
} catch (Exception e) {
logger.error(e.getMessage(), e);
if(name.toLowerCase().matches("^\\.customdata\\..*")){
// traitement specifique pour les custom data qui ne sont pas gerees par le WS:
// do not give the custom data to the view, to avoid wrong modification
}else {
// logger.error("LIST CONTENT ("+cpt+") " + elt);
// Non on ne test pas si c'est une propriete car c'est le contenu de la liste
// donc peut importe le type,
Class<?> eltClass = Object.class;
if (elt != null) {
eltClass = elt.getClass();
tree.appendChild(createTree(name + "." + cpt, elt, eltClass, tree, bypassNullObj));
} else {
try {
assert parent != null;
eltClass = (Class<?>) ObjectController.getClassTemplates(parent.getDataClass(),
name.substring(name.lastIndexOf(".") + 1)).getActualTypeArguments()[0];

logger.error("Trying to create with class : " + eltClass);
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
tree.appendChild(createTree(name + "." + cpt, elt, eltClass, tree, bypassNullObj));
}
tree.appendChild(createTree(name + "." + cpt, elt, eltClass, tree, bypassNullObj));
cpt++;
}
cpt++;
}
// On met la valeur a null car on met la valeur comme des enfants de l'arbre
tree.data = null;
Expand Down Expand Up @@ -359,11 +364,10 @@ public String toJSON() {
}

// TODO : faire les filtre de "typevalue" pour les classes finissant par "Ext"
// on cherche la classe de même nom sans "Ext" et on contraint en type enum
// on cherche la classe de meme nom sans "Ext" et on contraint en type enum

// Pour cela regarder le root elet pout avoir la version puis chercher si le
// package
// contient un type ext
// package contient un type ext

// boolean hasChildOrProperty = false;
// attributes
Expand All @@ -387,26 +391,37 @@ public String toJSON() {
// hasChildOrProperty = true;
}

// On met une valeur si ce n'est pas un array et si c'est un type modifiable
// directement (comme les proprietes)
if (data != null && !dataClass.getName().toLowerCase().endsWith("array")
&& ObjectController.isPropertyClass(data.getClass())) {
String dataAsString = data + "";
if (data.getClass().isEnum()) {
try {
Method m_enulValue = data.getClass().getMethod("value");
dataAsString = (String) m_enulValue.invoke(data);
} catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException
| InvocationTargetException ignore) {
// if(name.matches(".*[cC]ustom[dD]ata(\\.[Aa]ny)?\\.[\\d]+.\\w+")){
// // Traitement specifique pour les CustomData
// String dataAsString = Editor.pkgManager.marshal(data);
// if(dataAsString == null || dataAsString.length() <=0){
// Gson gson = new Gson();
// gson.toJson(data);
// jsonValue.append(" \"value\" : ").append(dataAsString).append("\n");
// }
// }else {
// On met une valeur si ce n'est pas un array et si c'est un type modifiable
// directement (comme les proprietes)
if (data != null && !dataClass.getName().toLowerCase().endsWith("array")
&& ObjectController.isPropertyClass(data.getClass())) {
String dataAsString = data + "";
if (data.getClass().isEnum()) {
try {
Method m_enumValue = data.getClass().getMethod("value");
dataAsString = (String) m_enumValue.invoke(data);
} catch (NoSuchMethodException | SecurityException | IllegalAccessException |
IllegalArgumentException
| InvocationTargetException ignore) {
}
}
dataAsString = Utility.transformStringForJsonCompatibility(dataAsString);
jsonValue.append(" \"value\" : ").append(dataAsString).append("\n");
} else if (data == null && ObjectController.isPrimitiveClass(dataClass)) {
jsonValue.append(" \"value\" : \"\"\n");
} else {
jsonValue = new StringBuilder(jsonValue.substring(0, jsonValue.lastIndexOf(",")) + " ");
}
dataAsString = Utility.transformStringForJsonCompatibility(dataAsString);
jsonValue.append(" \"value\" : ").append(dataAsString).append("\n");
} else if (data == null && ObjectController.isPrimitiveClass(dataClass)) {
jsonValue.append(" \"value\" : \"\"\n");
} else {
jsonValue = new StringBuilder(jsonValue.substring(0, jsonValue.lastIndexOf(",")) + " ");
}
// }
jsonValue.append("}");
return jsonValue.toString().replaceAll("\t", " ");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -394,15 +394,6 @@ private static Class<?> getClassMatchFromPrefix(String prefix, List<Class<?>> po
return null;
}

public static void main(String[] argv) {
// try {
// logger.error(getSubAttributeClass(".trianglePatch.0.splitEdgePatch.0.splitEdges", TriangulatedSetRepresentation.class, null));
// } catch (Exception e) {
// logger.error(e.getMessage(), e);
// }
}


public enum ModficationType {ADD_LIST_ELT, REMOVE_LIST_ELT, CREATE_ELT, EDITION}

}
10 changes: 9 additions & 1 deletion src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<session-config>
<session-timeout>30</session-timeout>
</session-config>

<servlet>
<servlet-name>Editor</servlet-name>
<servlet-class>com.geosiris.webstudio.servlet.Editor</servlet-class>
Expand Down Expand Up @@ -53,4 +53,12 @@
<listener-class>com.geosiris.webstudio.servlet.global.SessionCounter</listener-class>
</listener>

<filter>
<filter-name>SameSiteFilter</filter-name>
<filter-class>com.geosiris.webstudio.filters.SameSiteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>SameSiteFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
2 changes: 1 addition & 1 deletion src/main/webapp/jsp/htmlParts/bandeau.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ limitations under the License.
<span class="nav-link fas fa-users" style="display: none" id="sessionCounter" title="Other connected users count"></a>
</li>
<li class="nav-item active">
<h2 class="ws_title" id="ws_top_title">ResQML WebStudio</h2>
<h2 class="ws_title" id="ws_top_title">Energyml WebStudio</h2>
</li>
<li class="nav-item navbar-text">
<div id="taskInProgressRoling" class="spinner-border text-success"
Expand Down
3 changes: 2 additions & 1 deletion src/main/webapp/ressources/css/epcView.css
Original file line number Diff line number Diff line change
Expand Up @@ -343,9 +343,10 @@ label + input {
}

.typeCommentContainer{
color : black;
background: #f2f2f2;
z-index: 100;
border-radius: 30px;
border-radius: 10px;
border: 1px solid;
padding: 5px;
max-width: 800px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export function initSessionLogEventHandler(console_id){
//console.log("EVENT: ");
//console.log(decodedMsg);
};
rws_addEventListeners('logs', evt_list_onMessage, evt_list_onMessage);
rws_addEventListeners('logs', evt_list_onMessage, null);
}


Expand Down
2 changes: 1 addition & 1 deletion src/main/webapp/ressources/script/modules/UI/htmlUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export function createRadio(labelTxt, value, radioName, checkableOnclickFunc_Wit
radio.type = "radio";
radio.name = radioName;
radio.value = value;
radio.className = "form-check-input";
//radio.className = "form-check-input"; // create bug for the DOR interface
if(checked!=null){
radio.checked = checked;
}
Expand Down
8 changes: 6 additions & 2 deletions src/main/webapp/ressources/script/modules/UI/modals/etp.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,9 @@ export function loadETPObjectList(eltId_objectList, eltId_formRequest){
if(eltTable != null){
formDivTable.appendChild(eltTable);
}

while(divETP.firstChild){
divETP.removeChild(divETP.firstChild)
}
divETP.appendChild(formImportETPobjects); // On ajoute qu'une fois tout fini
setErrorsVisibility(divETP, false);
}catch(e){
Expand Down Expand Up @@ -495,7 +497,9 @@ export function populate_getRelated(formId, divResId, importRelatedFormId){
if(eltTable != null){
formDivTable.appendChild(eltTable);
}

while(divETP.firstChild){
divETP.removeChild(divETP.firstChild)
}
//divETP.appendChild(formImportETPobjects); // On ajoute qu'une fois tout fini
divETP.appendChild(formSubmit);
divETP.appendChild(formDivTable);
Expand Down
Loading

0 comments on commit 3c60a3e

Please sign in to comment.