Browse Source

feat: 表关联问题

upgrade-final
Zhenfei.Li 5 years ago
parent
commit
0dd30e4b62
  1. 51
      src/main/java/com/fr/plugin/decision/request/handler/UpgradeHandler.java

51
src/main/java/com/fr/plugin/decision/request/handler/UpgradeHandler.java

@ -10,6 +10,7 @@ import com.finebi.burger.api.service.FineTableService;
import com.finebi.common.api.cell.context.CellCreator; import com.finebi.common.api.cell.context.CellCreator;
import com.finebi.common.authority.api.FineAuthorityUtils; import com.finebi.common.authority.api.FineAuthorityUtils;
import com.finebi.common.authority.decision.role.FineAuthorityUser; import com.finebi.common.authority.decision.role.FineAuthorityUser;
import com.finebi.common.impl.vo.relation.FineBusinessRelation;
import com.finebi.common.impl.vo.table.FineDBBusinessTable; import com.finebi.common.impl.vo.table.FineDBBusinessTable;
import com.finebi.foundation.api.reponse.FineRespond; import com.finebi.foundation.api.reponse.FineRespond;
import com.finebi.foundation.api.service.FineService; import com.finebi.foundation.api.service.FineService;
@ -137,33 +138,35 @@ public class UpgradeHandler extends HWAbstractHandler {
if (StringUtils.equals("success", dmlResult.getString("status")) && dmlResult.getBoolean("addLink")) { if (StringUtils.equals("success", dmlResult.getString("status")) && dmlResult.getBoolean("addLink")) {
ExcelLinkService.getInstance().addLink(name, connection, schema, tableName, createUser); ExcelLinkService.getInstance().addLink(name, connection, schema, tableName, createUser);
FineLoggerFactory.getLogger().info("HW_excel导入:FineDB 新增数据成功" + name); FineLoggerFactory.getLogger().info("HW_excel导入:FineDB 新增数据成功" + name);
List<FineBusinessRelation> fineBusinessRelations = CellCreator.getCellProvider().relationPathCell().getRelationsByTableNameWithoutAuth(fineBusinessTable.getName());
CellCreator.getCellProvider().tableCell().removeTable(fineBusinessTable.getName(), FineAuthorityUser.ROOT_USER_ID); CellCreator.getCellProvider().tableCell().removeTable(fineBusinessTable.getName(), FineAuthorityUser.ROOT_USER_ID);
}
} catch(Exception e){
e.printStackTrace();
}
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
JSONObject table = JSONObject.create().put("tableName", fineBusinessTable.getName()).put("connectionName", connection); JSONObject table = JSONObject.create().put("tableName", fineBusinessTable.getName()).put("connectionName", connection);
JSONArray tables = JSONArray.create().put(table); JSONArray tables = JSONArray.create().put(table);
JSONObject tablesBean = JSONObject.create().put("tables", tables); JSONObject tablesBean = JSONObject.create().put("tables", tables);
try{ try{
FineAuthorityUser authorityUser = FineAuthorityUtils.getAuth(req); FineAuthorityUser authorityUser = FineAuthorityUtils.getAuth(req);
String packid = "__my_analysis__" + authorityUser.getUserId(); String packid = "__my_analysis__" + authorityUser.getUserId();
try { try {
String tableString = tablesBean.toString(); String tableString = tablesBean.toString();
FineBusinessTable[] businessTables = createBusinessTablesFromDBNewAddTableInfo(mapper.readValue(tableString, DataBaseAddTableRequestBean.class), authorityUser.getUserId()); FineBusinessTable[] businessTables = createBusinessTablesFromDBNewAddTableInfo(mapper.readValue(tableString, DataBaseAddTableRequestBean.class), authorityUser.getUserId());
TableAddResponseBean responed = getTableService().addNewTable(packid, authorityUser, businessTables); TableAddResponseBean responed = getTableService().addNewTable(packid, authorityUser, businessTables);
addDbResult.put(FineRespond.success(responed)); CellCreator.getCellProvider().relationPathCell().addRelations(fineBusinessRelations, authorityUser);
} catch (JsonMappingException e) { addDbResult.put(FineRespond.success(responed));
e.printStackTrace(); } catch (JsonMappingException e) {
} catch (JsonGenerationException e) { e.printStackTrace();
e.printStackTrace(); } catch (JsonGenerationException e) {
} catch (IOException e) { e.printStackTrace();
e.printStackTrace(); } catch (IOException e) {
e.printStackTrace();
}
}
catch(Exception e){
e.printStackTrace();
}
} }
} } catch(Exception e){
catch(Exception e){
e.printStackTrace(); e.printStackTrace();
} }

Loading…
Cancel
Save