Commit dbe38dc0 authored by Davide Zerbetto's avatar Davide Zerbetto
Browse files

Restored Jackson 2.9.2 and fixed bug in knowagemeta related to this Jackson...

Restored Jackson 2.9.2 and fixed bug in knowagemeta related to this Jackson library version: applied modifications as per revisions 12446 ("fixed GUI problem after jackson update (changed json syntax for Map.Entry)") and 12466 ("fixed problem with diff path for properties value change (after the upgrade of the version of jackson)") on trunk
parent df1831cf
......@@ -105,7 +105,7 @@
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
<version>2.0.2</version>
<version>2.9.2</version>
<scope>runtime</scope>
</dependency>
......
......@@ -17,56 +17,6 @@
*/
package it.eng.knowage.meta.service;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.nio.file.Files;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.naming.NamingException;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;
import org.apache.commons.io.IOUtils;
import org.apache.commons.jxpath.JXPathContext;
import org.apache.commons.jxpath.Pointer;
import org.apache.log4j.Logger;
import org.eclipse.emf.common.util.EList;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.safehaus.uuid.UUID;
import org.safehaus.uuid.UUIDGenerator;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.NullNode;
import com.fasterxml.jackson.databind.node.TextNode;
import com.flipkart.zjsonpatch.JsonDiff;
import it.eng.knowage.meta.exception.KnowageMetaException;
import it.eng.knowage.meta.generator.GenerationException;
import it.eng.knowage.meta.generator.jpamapping.JpaMappingJarGenerator;
......@@ -123,6 +73,57 @@ import it.eng.spagobi.utilities.exceptions.SpagoBIException;
import it.eng.spagobi.utilities.exceptions.SpagoBIServiceException;
import it.eng.spagobi.utilities.rest.RestUtilities;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.nio.file.Files;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.naming.NamingException;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;
import org.apache.commons.io.IOUtils;
import org.apache.commons.jxpath.JXPathContext;
import org.apache.commons.jxpath.Pointer;
import org.apache.log4j.Logger;
import org.eclipse.emf.common.util.EList;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.safehaus.uuid.UUID;
import org.safehaus.uuid.UUIDGenerator;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.NullNode;
import com.fasterxml.jackson.databind.node.TextNode;
import com.flipkart.zjsonpatch.JsonDiff;
@ManageAuthorization
@Path("/1.0/metaWeb")
public class MetaService extends AbstractSpagoBIResource {
......@@ -912,8 +913,8 @@ public class MetaService extends AbstractSpagoBIResource {
@POST
@Path("/updatePhysicalModel")
@SuppressWarnings("unchecked")
public Response applyUpdatePhysicalModel(@Context HttpServletRequest req)
throws ClassNotFoundException, NamingException, SQLException, JSONException, IOException {
public Response applyUpdatePhysicalModel(@Context HttpServletRequest req) throws ClassNotFoundException, NamingException, SQLException, JSONException,
IOException {
Model model = (Model) req.getSession().getAttribute(EMF_MODEL);
JSONObject oldJsonModel = createJson(model);
......@@ -928,7 +929,7 @@ public class MetaService extends AbstractSpagoBIResource {
}
currTables.addAll(tables);
PhysicalModel phyMod = physicalModelInitializer.initializeLigth(originalPM, currTables);
PhysicalModel phyMod = physicalModelInitializer.initializeLigth(originalPM.getConnection(), currTables);
physicalModelInitializer.updateModel(originalPM, phyMod, tables);
JSONObject jsonModel = createJson(model);
......@@ -1223,7 +1224,9 @@ public class MetaService extends AbstractSpagoBIResource {
private void applyDiff(JSONObject jsonRoot, Model model) throws SpagoBIException, JsonProcessingException, IOException, JSONException {
if (jsonRoot.has("diff")) {
JsonNode patch = new ObjectMapper().readTree(jsonRoot.getString("diff"));
ObjectMapper mapper = new ObjectMapper();
JsonNode patch = mapper.readTree(jsonRoot.getString("diff"));
applyPatch(patch, model);
}
}
......@@ -1370,6 +1373,26 @@ public class MetaService extends AbstractSpagoBIResource {
*/
private String cleanPath(String path) {
path = path.replaceAll("^/physicalModels", "/businessModels/0/tables").replaceAll("^/businessModels", "/businessModels/0/businessTables");
/*
* This regular expression will clean the path for editing properties of a model to
* have something compatible with the xpath expression. I.e:
*
* /businessModels/0/columns/0/properties/7/behavioural.notEnabledRoles/value
*
* will be changed to:
*
* /businessModels/0/columns/0/properties/7/value/value
*
* So the property name is replaced by "value"
*
*/
if (path.contains("properties")) {
String regex = "(?<=properties\\/\\d\\/).*?(?=\\/value)";
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(path);
path = matcher.replaceAll("value");
}
Pattern p = Pattern.compile("(/)(\\d+)");
Matcher m = p.matcher(path);
StringBuffer s = new StringBuffer();
......
......@@ -84,45 +84,39 @@
<expander-box layout-margin layout="column" expanded="true" label="catProp" background-color="transparent" color="black" ng-repeat="catProp in currentBusinessModelParameterCategories | filterByMainCategory">
<md-input-container ng-repeat="prop in selectedBusinessModel.properties | filterByCategory:catProp"
ng-class=" {'md-icon-right' : (prop.value.value=='temporal dimension' || prop.value.value=='time dimension') }"
ng-init="prop.value.value= (prop.value.value==undefined || prop.value.value==null) ? prop.value.propertyType.defaultValue : prop.value.value">
<label>{{prop.value.propertyType.name}}</label>
<md-select ng-model="prop.value.value" ng-if="prop.value.propertyType.admissibleValues.length!=0">
<md-option ng-repeat="admissibleValue in prop.value.propertyType.admissibleValues | filterByProductType:prop " value="{{admissibleValue}}" >
ng-class=" {'md-icon-right' : (getPropertyAttributes(prop).value=='temporal dimension' || getPropertyAttributes(prop).value=='time dimension') }"
ng-init="getPropertyAttributes(prop).value= (getPropertyAttributes(prop).value==undefined || getPropertyAttributes(prop).value==null) ? getPropertyAttributes(prop).propertyType.defaultValue : getPropertyAttributes(prop).value">
<label>{{getPropertyAttributes(prop).propertyType.name}}</label>
<md-select ng-model="getPropertyAttributes(prop).value" ng-if="getPropertyAttributes(prop).propertyType.admissibleValues.length!=0">
<md-option ng-repeat="admissibleValue in getPropertyAttributes(prop).propertyType.admissibleValues | filterByProductType:prop " value="{{admissibleValue}}" >
{{admissibleValue}}
</md-option>
</md-select>
<input ng-if="prop.value.propertyType.admissibleValues.length==0
&& prop.key!='structural.attribute'
&& prop.key!='behavioural.notEnabledRoles'" ng-model="prop.value.value">
<input ng-if="getPropertyAttributes(prop).propertyType.admissibleValues.length==0
&& getPropertyKey(prop)!='structural.attribute'
&& getPropertyKey(prop)!='behavioural.notEnabledRoles'" ng-model="getPropertyAttributes(prop).value">
<!--profile attributes visibility -->
<md-select ng-model="prop.value.value" ng-if="prop.key=='structural.attribute'" >
<md-option value=""></md-option>
<md-select ng-model="getPropertyAttributes(prop).value" ng-if="getPropertyKey(prop)=='structural.attribute'" >
<md-option ng-repeat="admissibleValue in sbiModule_config.profileAttributes " value="{{admissibleValue}}" >
{{admissibleValue}}
</md-option>
</md-select>
<!--profile role visibility -->
<md-select ng-model="tmpRoleVisibility" ng-if="prop.key=='behavioural.notEnabledRoles'" multiple
ng-init="tmpRoleVisibility=[];initRoleVisibility(tmpRoleVisibility,prop.value.value)" md-on-close="buildRoleVisibility(tmpRoleVisibility,prop.value)">
<md-option ng-repeat="role in sbiModule_config.avaiableRoles" value="{{role}}" >
<md-select ng-model="tmpRoleVisibility" ng-if="getPropertyKey(prop)=='behavioural.notEnabledRoles'" multiple
ng-init="tmpRoleVisibility=[];initRoleVisibility(tmpRoleVisibility,getPropertyAttributes(prop).value)"
md-on-close="buildRoleVisibility(tmpRoleVisibility,getPropertyAttributes(prop))">
<md-option ng-repeat="role in sbiModule_config.avaiableRoles track by $index" value="{{role}}" >
{{role}}
</md-option>
</md-select>
<!-- physical column name -->
<md-input-container ng-if="(selectedBusinessModel['physicalColumn']!=undefined) && (catProp=='physical')">
<label >{{translate.load("sbi.meta.column.physical")}}</label>
<input ng-if="(selectedBusinessModel['physicalColumn']!=undefined) && (catProp=='physical')" ng-model="selectedBusinessModel['physicalColumn'].name" disabled>
</md-input-container>
<!-- edit temporal hierarchy button -->
<md-icon ng-if="prop.value.value=='temporal dimension'" ng-click="editTemporalHierarchy()" md-font-icon=" fa fa-sitemap" ></md-icon>
<md-icon ng-if="prop.value.value=='time dimension'" ng-click="editTemporalHierarchy()" md-font-icon=" fa fa-sitemap" ></md-icon>
<md-icon ng-if="getPropertyAttributes(prop).value=='temporal dimension'" ng-click="editTemporalHierarchy()" md-font-icon=" fa fa-sitemap" ></md-icon>
<md-icon ng-if="getPropertyAttributes(prop).value=='time dimension'" ng-click="editTemporalHierarchy()" md-font-icon=" fa fa-sitemap" ></md-icon>
</md-input-container>
</expander-box>
</md-content>
......
......@@ -49,9 +49,9 @@
<expander-box layout="column" layout-margin expanded="true" label="catProp" background-color="transparent" color="black" ng-repeat="catProp in currentPhysicalModelParameterCategories">
<md-input-container ng-repeat="prop in selectedPhysicalModel.properties | filterByCategory:catProp"
ng-init="prop.value.value= (prop.value.value==undefined || prop.value.value==null) ? prop.value.propertyType.defaultValue : prop.value.value">
<label>{{prop.value.propertyType.name}}</label>
<input ng-model="prop.value.value" disabled>
ng-init="getPropertyAttributes(prop).value= (getPropertyAttributes(prop).value==undefined || getPropertyAttributes(prop).value==null) ? getPropertyAttributes(prop).propertyType.defaultValue : getPropertyAttributes(prop).value">
<label>{{getPropertyAttributes(prop).propertyType.name}}</label>
<input ng-model="getPropertyAttributes(prop).value" disabled>
</md-input-container>
</expander-box>
</md-content>
......
......@@ -20,11 +20,12 @@ function addCalculatedFieldController($scope, $mdDialog,sbiModule_translate,sbiM
$scope.calcField.name=currentCF.name
for(var i=0;i<currentCF.properties.length;i++){
if(angular.equals(currentCF.properties[i].key,"structural.datatype")){
$scope.calcField.dataType=currentCF.properties[i].value.value
var key = Object.keys(currentCF.properties[i])[0];
if(angular.equals(key,"structural.datatype")){
$scope.calcField.dataType=currentCF.properties[i][key].value
}
if(angular.equals(currentCF.properties[i].key,"structural.expression")){
$scope.calcField.expression=currentCF.properties[i].value.value
if(angular.equals(key,"structural.expression")){
$scope.calcField.expression=currentCF.properties[i][key].value
}
}
}
......
......@@ -16,14 +16,15 @@ function editTemporalHierarchyController($scope,sbiModule_translate,sbiModule_re
tmpH.properties={};
for(var p=0;p<currH.properties.length;p++){
var currProp=currH.properties[p];
var val=currProp.value.value || currProp.value.propertyType.defaultValue;
var key = Object.keys(currProp)[0];
var val=currProp.value || currProp.propertyType.defaultValue;
if(angular.equals(val,"true")){
val=true;
}
if(angular.equals(val,"false")){
val=false;
}
tmpH.properties[currProp.value.propertyType.id.split(".")[1]]=val;
tmpH.properties[currProp.propertyType.id.split(".")[1]]=val;
}
tmpH.levels=[];
......@@ -32,8 +33,9 @@ function editTemporalHierarchyController($scope,sbiModule_translate,sbiModule_re
//load the current levels levelType from the properties
for(var pro=0;pro<currL.properties.length;pro++){
if(angular.equals(currL.properties[pro].key.split(".")[1],"leveltype")){
currL.leveltype=currL.properties[pro].value.value;
var key = Object.keys(currL.properties[pro])[0];
if(angular.equals(key.split(".")[1],"leveltype")){
currL.leveltype=currL.properties[pro][key].value;
}
}
......
......@@ -291,8 +291,9 @@ angular.module('metaManager').filter('filterByCategory', function(sbiModule_user
return function(items, categoryName) {
var filtered = [];
angular.forEach(items, function(item) {
if (angular.equals(item.key.split(".")[0], categoryName)) {
if (categoryName == "behavioural" || item.key == "structural.attribute"){
var key = Object.keys(item)[0];
if (angular.equals(key.split(".")[0], categoryName)) {
if (categoryName == "behavioural" || key == "structural.attribute"){
if (showDataProfiling == true) {
filtered.push(item);
}
......@@ -310,8 +311,9 @@ angular.module('metaManager').filter('filterByProductType', function(sbiModule_c
var showSpatialDimension = sbiModule_user.functionalities.indexOf("SpatialDimension")>-1;
var showTemporalDimension = sbiModule_user.functionalities.indexOf("TemporalDimension")>-1;
if(angular.equals(prop.value.propertyType.name,"Type")){
var key = Object.keys(prop)[0];
if(angular.equals(prop[key].propertyType.name,"Type")){
if(sbiModule_config.productTypes.indexOf("KnowageLI")==-1 || !showSpatialDimension){
//remove spatial dimension
var sdInd=items.indexOf("geographic dimension");
......@@ -349,7 +351,8 @@ angular.module('metaManager').service("parametersBuilder", function() {
var propertiesCat = [];
for (var i = 0; i < properties.length; i++) {
var tmpProp = properties[i];
var struct = tmpProp.key.split(".");
var key = Object.keys(tmpProp)[0];
var struct = key.split(".");
if (propertiesCat.indexOf(struct[0]) == -1) {
propertiesCat.push(struct[0]);
}
......
......@@ -131,6 +131,11 @@ function metaModelCreationPhysicalControllerFunction($scope, sbiModule_translate
}
}
]
$scope.getPropertyAttributes = function(prop){
return prop[Object.keys(prop)[0]];
}
}
function metaModelCreationBusinessControllerFunction($scope, sbiModule_translate,sbiModule_restServices, parametersBuilder,$timeout,$mdDialog,sbiModule_config,metaModelServices,$mdPanel,sbiModule_config,sbiModule_user){
......@@ -168,8 +173,9 @@ function metaModelCreationBusinessControllerFunction($scope, sbiModule_translate
$scope.getBusinessModelType=function(bm){
var prop=bm.properties;
for(var i=0;i<prop.length;i++){
if(angular.equals(prop[i].key,"structural.tabletype")){
return prop[i].value.value;
var key = Object.keys(prop[i])[0];
if(angular.equals(key,"structural.tabletype")){
return prop[i][key].value;
}
}
return "generic";
......@@ -178,8 +184,9 @@ function metaModelCreationBusinessControllerFunction($scope, sbiModule_translate
$scope.getBusinessModelColumnsType=function(bm){
var prop=bm.properties;
for(var i=0;i<prop.length;i++){
if(angular.equals(prop[i].key,"structural.columntype")){
return prop[i].value.value;
var key = Object.keys(prop[i])[0];
if(angular.equals(key,"structural.columntype")){
return prop[i][key].value;
}
}
};
......@@ -292,6 +299,7 @@ function metaModelCreationBusinessControllerFunction($scope, sbiModule_translate
}
function businessModelPropertyControllerFunction($scope, sbiModule_translate,sbiModule_restServices, parametersBuilder,$timeout){
$scope.businessModelMiscInfo = [ {
name : "name",
label : sbiModule_translate.load("name")
......@@ -310,6 +318,14 @@ function businessModelPropertyControllerFunction($scope, sbiModule_translate,sbi
$scope.buildRoleVisibility=function(rv,val){
val.value=rv.join(";");
}
$scope.getPropertyAttributes = function(prop){
return prop[Object.keys(prop)[0]];
}
$scope.getPropertyKey = function(prop){
return Object.keys(prop)[0];
}
}
function businessModelAttributeControllerFunction($scope, sbiModule_translate,sbiModule_restServices, parametersBuilder,$timeout,$mdDialog,sbiModule_config,metaModelServices ){
......
......@@ -583,6 +583,12 @@
<version>4.3.1</version>
</dependency>
<dependency>
<groupId>com.auth0</groupId>
<artifactId>java-jwt</artifactId>
<version>3.3.0</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment