private void executeDimensionProc( String bm_tag, CompositeMap dimensionsRecords, CompositeMap context) throws Exception { if (dimensionsRecords == null || dimensionsRecords.getChilds() == null) return; IProcedureManager procedureManager = (IProcedureManager) objectRegistry.getInstanceOfType(IProcedureManager.class); if (procedureManager == null) throw BuiltinExceptionFactory.createInstanceNotFoundException(this, IProcedureManager.class); for (Iterator it = dimensionsRecords.getChildIterator(); it.hasNext(); ) { CompositeMap dimension = (CompositeMap) it.next(); String dimension_init_proc = dimension.getString(KEY_DIMENSION_INIT_PROC); String tag = dimension.getString("dimension_tag"); if (tag == null) continue; boolean is_tag_match = bm_tag.contains(tag); if (dimension_init_proc != null && is_tag_match) { Procedure proc = null; try { proc = procedureManager.loadProcedure(dimension_init_proc); } catch (Exception ex) { throw BuiltinExceptionFactory.createResourceLoadException( context.asLocatable(), dimension_init_proc, ex); } ServiceInstance svc = ServiceInstance.getInstance(context); svc.invoke(proc); } } }
public void addConsumer(CompositeMap processor) { List childs = processor.getChilds(); if (childs == null) ; if (childs.size() != 1) ; CompositeMap child = (CompositeMap) childs.get(0); Object inst = mOCManager.createObject(child); if (inst == null || !(inst instanceof IResultSetConsumer)) ; rsConsummer = (IResultSetConsumer) inst; }
public void setData(CompositeMap data) throws ApplicationException { this.data = data; if (tableViewer != null) { createDefaultActions(); if (tableViewer.getColumnProperties() == null) createTableColumns(); if (data != null && data.getChilds() != null) { tableViewer.setInput(data); if (isAllChecked()) setAllChecked(tableViewer.getTable(), true); } } }
public static void getKeyNodeMap(CompositeMap source, Object key, Map result) { if (source == null || key == null) return; Object value = source.get(key); if (value != null) { result.put(value, source); } if (source.getChilds() != null) { for (Iterator it = source.getChildIterator(); it.hasNext(); ) { getKeyNodeMap((CompositeMap) it.next(), key, result); } } }
public void refresh(boolean dirty) { if (dirty && parent != null) parent.refresh(true); else { if (tableViewer != null && !tableViewer.getTable().isDisposed()) { if (data != null && data.getChilds() != null) { labelProvider.refresh(); tableViewer.setInput(data); } else { tableViewer.getTable().removeAll(); } } } }
private void init(BuildSession session, ViewContext view_context) throws Exception { CompositeMap context = ServiceThreadLocal.getCurrentThreadContext(); if (context == null) throw new IllegalStateException("No service context set in ThreadLocal yet"); CompositeMap view = view_context.getView(); CompositeMap base_model = view_context.getModel(); HTMLIncludeConfig hic = HTMLIncludeConfig.getInstance(view); String path = TextParser.parse(hic.getPath(), base_model); version = TextParser.parse(hic.getVersion(), base_model); if (null != path && !path.isEmpty()) { int begin = path.indexOf("/release"); if (begin < 0) return; path = path.substring(begin, path.length()); articlePath = "../.." + path; sourcePath = session.getContextPath() + path.replaceAll("\\\\", "/").replaceAll("(.*/)[^/]*$", "$1"); return; } String pathField = hic.getPathField(); String model = hic.getModel(); CompositeMap params = hic.getParams(); Map map = new HashMap(); if (null != params) { Iterator pit = params.getChildIterator(); while (pit.hasNext()) { CompositeMap param = (CompositeMap) pit.next(); map.put( param.get("name"), TextParser.parse((String) param.get("value"), view_context.getModel())); } } BusinessModelService service = factory.getModelService(model, context); CompositeMap resultMap = service.queryAsMap(map); if (null == resultMap || null == resultMap.getChilds()) { throw new ClassNotFoundException("文章未找到,输入的路径不正确。"); } Iterator it = resultMap.getChildIterator(); while (it.hasNext()) { path = ((CompositeMap) it.next()).getString(pathField); if (null != path) { articlePath = "../.." + path; sourcePath = session.getContextPath() + path.replaceAll("\\\\", "/").replaceAll("(.*/)[^/]*$", "$1"); break; } } }
public static CompositeMap searchNodeById(CompositeMap source, String targetId) { if (source == null || targetId == null) return null; CompositeMap targetNode = null; String nodeId = source.getString("id"); if (nodeId != null && targetId.equals(nodeId)) { return source; } List<CompositeMap> childList = source.getChilds(); if (childList != null) { for (CompositeMap child : childList) { targetNode = searchNodeById(child, targetId); if (targetNode != null) break; } } return targetNode; }
private void addFields() { String pkName = null; if (primaryKeys != null && primaryKeys.getChildsNotNull().size() == 1) { pkName = ((CompositeMap) primaryKeys.getChilds().get(0)).getString("name"); } if (pkName != null) { model.getPkRecord().setName(pkName); } @SuppressWarnings("unchecked") List<CompositeMap> list = selection.getChildsNotNull(); for (CompositeMap m : list) { String column_name = m.getString("name"); if (pkName != null && pkName.equalsIgnoreCase(column_name)) continue; Record r = model.getRecordByName(column_name); if (r == null) { r = DesignerUtil.createRecord(m); model.add(r); } } ((BMDesignPage) designer.getActivePageInstance()).refreshRecordViewer(); }
public void run(ProcedureRunner runner) throws Exception { runner.getContext().putObject(PATH_NAME, this, true); super.run(runner); ServiceInstance svc = ServiceInstance.getInstance(runner.getContext()); CompositeMap root = svc.getServiceConfigData().getRoot(); Map holders = (Map) root.get(PlaceHolder.PLACEHOLDER); if (holders != null) { CompositeMap holder = (CompositeMap) holders.get(targetId); if (holder != null) { CompositeMap parent = holder.getParent(); Iterator it = getResultList().iterator(); while (it.hasNext()) { CompositeMap cm = (CompositeMap) it.next(); cm.setParent(parent); } List children = parent.getChilds(); children.addAll(children.indexOf(holder), getResultList()); children.remove(holder); } } }
@Override public CompositeMap getCustomizationData( BusinessModel model, String function_code, CompositeMap context) { if (custDimensionsRecords == null || custDimensionsRecords.getChilds() == null) return null; String bm_name = model.getName(); SqlServiceContext ssc = null; ResultSet rs_exists = null; ResultSet rs_details = null; CompositeMap result = new CompositeMap("result"); try { ssc = databaseServiceFactory.createContextWithConnection(); String exits_sql = "select 1 from dual where exists (select 1 from sys_bm_config_customization t " + " where t.bm_code='" + bm_name + "' and t.function_code = '" + function_code + "' and t.enable_flag='Y')"; ParsedSql exits_stmt = createStatement(exits_sql); SqlRunner exits_runner = new SqlRunner(ssc, exits_stmt); rs_exists = exits_runner.query(null); if (!rs_exists.next()) { return null; } String bm_tag = model.getTag(); if (bm_tag != null) { executeDimensionProc(bm_tag, custDimensionsRecords, context); } String dimenson_sql_template = "select d.order_num,record_id,head_id,function_id,function_code,bm_code,dimension_type,dimension_value," + " bm_select_value,bm_data_source,bm_where_clause,bm_order_by,bm_query_condition" + " from sys_bm_config_customization t,sys_bm_config_dimension d " + " where t.dimension_type=d.dimension_code and t.enable_flag = 'Y'" + " and t.bm_code='" + bm_name + "' and t.function_code = '" + function_code + "' and t.dimension_type="; StringBuffer sb = new StringBuffer(""); boolean firstRecord = true; for (Iterator it = custDimensionsRecords.getChildIterator(); it.hasNext(); ) { CompositeMap record = (CompositeMap) it.next(); String dimensionCode = record.getString("dimension_code"); String data_query_sql = record.getString("data_query_sql"); String dimension_tag = record.getString("dimension_tag"); if (dimension_tag != null) { if (bm_tag == null) continue; boolean is_tag_match = bm_tag.contains(dimension_tag); if (!is_tag_match) continue; } if (firstRecord) firstRecord = false; else sb.append(" union all "); sb.append(dimenson_sql_template).append("'").append(dimensionCode).append("'"); if (data_query_sql != null) sb.append(" and ").append(data_query_sql); } if (!firstRecord) sb.append(" order by 1 "); if ("".equals(sb.toString())) return null; String custDetailRecordsSql = sb.toString(); LoggingContext.getLogger(context, this.getClass().getCanonicalName()) .config("custDetailRecordsSql:" + custDetailRecordsSql); ParsedSql stmt = createStatement(custDetailRecordsSql); SqlRunner runner = new SqlRunner(ssc, stmt); rs_details = runner.query(context); ResultSetLoader mRsLoader = new ResultSetLoader(); mRsLoader.setFieldNameCase(Character.LOWERCASE_LETTER); FetchDescriptor desc = FetchDescriptor.fetchAll(); CompositeMapCreator compositeCreator = new CompositeMapCreator(result); mRsLoader.loadByResultSet(rs_details, desc, compositeCreator); if (result.getChilds() == null) return null; } catch (Exception e) { throw new RuntimeException(e); } finally { DBUtil.closeResultSet(rs_exists); DBUtil.closeResultSet(rs_details); if (ssc != null) try { ssc.freeConnection(); } catch (SQLException e) { throw new RuntimeException(e); } } context.putObject(DEFAULT_CUSTOM_DATA, result); return result; }
public void run(ProcedureRunner runner) throws Exception { CompositeMap context = runner.getContext(); logger = LoggingContext.getLogger(context, LOGGING_TOPIC); logger.config("jco-invoke"); logger.config("==================================="); logger.log(Level.CONFIG, "config:{0}", new Object[] {this}); ServiceInstance service = (ServiceInstance) ServiceInstance.getInstance(context.getRoot()); // HttpServiceInstance service = (HttpServiceInstance) HttpServiceInstance // .getInstance(context.getRoot()); CompositeMap target = null; CompositeMap model = null; if (service != null) model = service.getServiceContext().getModel(); else model = context.getRoot().getChild("model"); if (model == null) model = context.getRoot().createChild("model"); if (return_target != null) { String t = TextParser.parse(return_target, context); target = (CompositeMap) model.getObject(t); if (target == null) target = model.createChildByTag(t); } JCoDestination destination = sapConfig.getJCoDestination(sid); String functionName = function; JCoFunctionTemplate ftemplate = destination.getRepository().getFunctionTemplate(functionName); logger.info("function template:" + functionName); if (ftemplate == null) { logger.log(Level.SEVERE, "Function '" + function + "' not found in SAP system."); throw new IllegalArgumentException("Function '" + function + "' not found in SAP system."); } // Create a function from the template JCoFunction function = ftemplate.getFunction(); JCoParameterList input = function.getImportParameterList(); JCoParameterList output = function.getExportParameterList(); if (parameters != null) for (int i = 0; i < parameters.length; i++) { Parameter param = parameters[i]; if (param.Return_field == null) { Object o = param.Source_field == null ? param.Value : context.getObject(param.Source_field); String value = o == null ? "" : o.toString(); input.setValue(param.Name, value); logger.log(Level.CONFIG, "parameter {0} -> {1}", new Object[] {param.Name, value}); } } if (structures != null) { for (int i = 0; i < structures.length; i++) { Structure structure = structures[i]; structure.setLogger(logger); if (structure.isImport()) { JCoStructure stc = structure.getJCOStructure(input); structure.fillJCOStructure(stc, context); input.setValue(structure.Name, stc); } } } // Set import table if (tables != null) { JCoParameterList list = function.getTableParameterList(); for (int i = 0; i < tables.length; i++) { Table table = tables[i]; table.setLogger(logger); if (table.isImport()) { JCoTable tbl = table.getJCOTable(list); Object o = context.getObject(table.Source_field); logger.config( "transfer import table " + table.Name + " from '" + table.Source_field + "':" + o); if (o instanceof CompositeMap) table.fillJCOTable(tbl, (CompositeMap) context); } } } // Call the remote system and retrieve return value logger.config("call function " + function); function.execute(destination); if (parameters != null) { for (int i = 0; i < parameters.length; i++) { Parameter param = parameters[i]; if (param.Return_field != null) { if (target == null) throw new ConfigurationError( "<jco-invoke>:must set 'return_target' attribute if there is return field"); String vl = output.getString(param.Name); if (vl == null && !param.Nullable) throw new IllegalArgumentException( "jco-invoke: return field " + param.Name + " is null"); String f = TextParser.parse(param.Return_field, context); target.putObject(f, vl); logger.config("return: " + param.Name + "=" + vl + " -> " + f); } } } if (structures != null) { for (int i = 0; i < structures.length; i++) { Structure structure = structures[i]; structure.setLogger(logger); if (structure.isImport()) continue; if (structure.Target == null) throw new ConfigurationError( "Must set 'target' attribute for Structures " + structure.Name); JCoStructure stc = structure.getJCOStructure(output); CompositeMap result = (CompositeMap) context.getObject(structure.Target); if (result == null) result = context.createChildByTag(structure.Target); structure.fillCompositeMap(stc, result); } } // Get export tables if (tables != null) { JCoParameterList list = function.getTableParameterList(); if (list == null) throw new IllegalArgumentException("Function '" + function + "' doesn't return tables"); for (int i = 0; i < tables.length; i++) { Table table = tables[i]; if (table.isImport()) continue; if (table.Target == null) throw new ConfigurationError("Must set 'target' attribute for table " + table.Name); table.setLogger(logger); JCoTable records = table.getJCOTable(list); // Fetch as CompositeMap CompositeMap result = (CompositeMap) context.getObject(table.Target); if (result == null) result = context.createChildByTag(table.Target); table.fillCompositeMap(records, result); int rc = 0; if (result.getChilds() != null) rc = result.getChilds().size(); logger.config( "loading export table " + table.Name + " into path '" + table.Target + "', total " + rc + " record(s)"); } } }
public void addTransformList(CompositeMap tlist) { transform_list = tlist.getChilds(); }