Search in sources :

Example 1 with SuFormProperties

use of com.qlangtech.tis.extension.impl.SuFormProperties in project tis by qlangtech.

the class DataxReader method createDataXReaderKey.

private static TIS.DataXReaderAppKey createDataXReaderKey(IPluginContext pluginContext, boolean db, String appname) {
    return new TIS.DataXReaderAppKey(pluginContext, db, appname, new PluginStore.IPluginProcessCallback<DataxReader>() {

        @Override
        public void afterDeserialize(final DataxReader reader) {
            List<PluginFormProperties> subFieldFormPropertyTypes = reader.getDescriptor().getSubPluginFormPropertyTypes();
            if (subFieldFormPropertyTypes.size() > 0) {
                // 加载子字段
                subFieldFormPropertyTypes.forEach((pt) -> {
                    pt.accept(new PluginFormProperties.IVisitor() {

                        @Override
                        public Void visit(final SuFormProperties props) {
                            SubFieldFormAppKey<DataxReader> subFieldKey = new SubFieldFormAppKey<>(pluginContext, db, appname, props, DataxReader.class);
                            KeyedPluginStore<DataxReader> subFieldStore = KeyedPluginStore.getPluginStore(subFieldKey);
                            // 子表单中的内容更新了之后,要同步父表单中的状态
                            subFieldStore.addPluginsUpdateListener(new PluginStore.PluginsUpdateListener<DataxReader>(subFieldKey.getSerializeFileName(), reader) {

                                @Override
                                public void accept(PluginStore<DataxReader> pluginStore) {
                                    setReaderSubFormProp(props, pluginStore.getPlugin());
                                }
                            });
                            DataxReader subFieldReader = subFieldStore.getPlugin();
                            if (subFieldReader == null) {
                                return null;
                            }
                            setReaderSubFormProp(props, subFieldReader);
                            return null;
                        }

                        private void setReaderSubFormProp(SuFormProperties props, DataxReader subFieldReader) {
                            setReaderSubFormProp(props, reader, subFieldReader);
                        }

                        private void setReaderSubFormProp(SuFormProperties props, DataxReader reader, DataxReader subFieldReader) {
                            if (reader == null) {
                                return;
                            }
                            try {
                                props.subFormField.set(reader, props.subFormField.get(subFieldReader));
                            } catch (IllegalAccessException e) {
                                throw new RuntimeException("get subField:" + props.getSubFormFieldName(), e);
                            }
                        }
                    });
                });
            }
        }
    });
}
Also used : StringUtils(org.apache.commons.lang.StringUtils) java.util(java.util) PluginStore(com.qlangtech.tis.plugin.PluginStore) TIS(com.qlangtech.tis.TIS) Descriptor(com.qlangtech.tis.extension.Descriptor) IPluginContext(com.qlangtech.tis.util.IPluginContext) Lists(com.google.common.collect.Lists) Public(com.qlangtech.tis.annotation.Public) IDataXPluginMeta(com.qlangtech.tis.datax.IDataXPluginMeta) IDataxReader(com.qlangtech.tis.datax.IDataxReader) SuFormProperties(com.qlangtech.tis.extension.impl.SuFormProperties) KeyedPluginStore(com.qlangtech.tis.plugin.KeyedPluginStore) IPluginStore(com.qlangtech.tis.plugin.IPluginStore) Describable(com.qlangtech.tis.extension.Describable) PluginFormProperties(com.qlangtech.tis.extension.PluginFormProperties) IDataxReader(com.qlangtech.tis.datax.IDataxReader) PluginStore(com.qlangtech.tis.plugin.PluginStore) KeyedPluginStore(com.qlangtech.tis.plugin.KeyedPluginStore) IPluginStore(com.qlangtech.tis.plugin.IPluginStore) SuFormProperties(com.qlangtech.tis.extension.impl.SuFormProperties)

Example 2 with SuFormProperties

use of com.qlangtech.tis.extension.impl.SuFormProperties in project plugins by qlangtech.

the class TestDataxMySQLReader method testUpdateDataxReader.

/**
 * 这个单元测试很重要
 *
 * @throws Exception
 */
public void testUpdateDataxReader() throws Exception {
    KeyedPluginStore<DataxReader> readerStore = DataxReader.getPluginStore(null, dataXName);
    final SuFormProperties props = EasyMock.createMock("subformProp", SuFormProperties.class);
    EasyMock.expect(props.getSubFormFieldName()).andReturn("selectedTabs").anyTimes();
    EasyMock.replay(props);
    DataxReader.SubFieldFormAppKey<DataxReader> subFieldKey = new DataxReader.SubFieldFormAppKey<>(null, false, dataXName, props, DataxReader.class);
    KeyedPluginStore<DataxReader> subFieldStore = KeyedPluginStore.getPluginStore(subFieldKey);
    File targetFile = readerStore.getTargetFile();
    FileUtils.deleteQuietly(targetFile);
    FileUtils.deleteQuietly(subFieldStore.getTargetFile());
    DataxMySQLReader dataxReader = (DataxMySQLReader) readerStore.getPlugin();
    assertNull("targetFile:" + targetFile.getAbsolutePath(), dataxReader);
    List<Descriptor.ParseDescribable<DataxReader>> dlist = Lists.newArrayList();
    dataxReader = new DataxMySQLReader();
    dataxReader.dbName = dbName;
    dataxReader.fetchSize = 1999;
    dataxReader.template = DataxMySQLReader.getDftTemplate();
    dataxReader.dataXName = dataXName;
    dlist.add(new Descriptor.ParseDescribable<>(dataxReader));
    readerStore.setPlugins(null, Optional.empty(), dlist);
    dataxReader = (DataxMySQLReader) readerStore.getPlugin();
    assertNotNull(dataxReader);
    assertTrue("dataxReader.getSelectedTabs() must be empty", CollectionUtils.isEmpty(dataxReader.getSelectedTabs()));
    dlist = Lists.newArrayList();
    DataxMySQLReader subformReader = new DataxMySQLReader();
    SelectedTab tabOrder = new SelectedTab();
    tabOrder.name = TestSelectedTabs.tabNameOrderDetail;
    tabOrder.setCols(TestSelectedTabs.tabColsMetaOrderDetail.stream().map((c) -> c.getName()).collect(Collectors.toList()));
    subformReader.setSelectedTabs(Collections.singletonList(tabOrder));
    dlist.add(new Descriptor.ParseDescribable(subformReader));
    subFieldStore.setPlugins(null, Optional.empty(), dlist);
    assertFalse("must not dirty", dataxReader.isDirty());
    // 这里有点像变魔术,这是通过 DataXReader中addPluginsUpdateListener添加的回调函数实现的
    assertTrue(dataxReader.getSelectedTabs().size() > 0);
    dataxReader.getSelectedTabs().forEach((t) -> {
        t.getCols().forEach((c) -> {
            assertNotNull("col:" + c.getName(), c.isPk());
            assertNotNull("col:" + c.getName(), c.getType());
        });
    });
    // 子form中再加一个tab
    SelectedTab tabTotalpayinfo = new SelectedTab();
    tabTotalpayinfo.name = TestSelectedTabs.tabNameTotalpayinfo;
    tabTotalpayinfo.setCols(TestSelectedTabs.tabColsMetaTotalpayinfo.stream().map((c) -> c.getName()).collect(Collectors.toList()));
    subformReader.setSelectedTabs(Lists.newArrayList(tabOrder, tabTotalpayinfo));
    dlist = Lists.newArrayList();
    dlist.add(new Descriptor.ParseDescribable(subformReader));
    subFieldStore.setPlugins(null, Optional.empty(), dlist);
    assertEquals(2, dataxReader.getSelectedTabs().size());
    dataxReader.getSelectedTabs().forEach((t) -> {
        t.getCols().forEach((c) -> {
            assertNotNull("tab:" + t.getName() + ",col:" + c.getName() + " relevant PK can not be null", c.isPk());
            assertNotNull("tab:" + t.getName() + ",col:" + c.getName() + " relevant Type can not be null", c.getType());
        });
    });
    DataxMySQLReader oldReader = dataxReader;
    dataxReader = new DataxMySQLReader();
    dataxReader.dbName = dbName;
    dataxReader.fetchSize = 2999;
    dataxReader.template = DataxMySQLReader.getDftTemplate();
    dataxReader.dataXName = dataXName;
    readerStore.setPlugins(null, Optional.empty(), Collections.singletonList(new Descriptor.ParseDescribable(dataxReader)));
    assertTrue("oldReader must be dirty", oldReader.isDirty());
    assertTrue(dataxReader.getSelectedTabs().size() > 0);
    // 清空测试
    dlist = Lists.newArrayList();
    subformReader = new DataxMySQLReader();
    dlist.add(new Descriptor.ParseDescribable(subformReader));
    subFieldStore.setPlugins(null, Optional.empty(), dlist);
    assertTrue("getSelectedTabs shall be empty", dataxReader.getSelectedTabs().size() < 1);
    EasyMock.verify(props);
}
Also used : DataxReader(com.qlangtech.tis.datax.impl.DataxReader) Descriptor(com.qlangtech.tis.extension.Descriptor) SuFormProperties(com.qlangtech.tis.extension.impl.SuFormProperties) File(java.io.File)

Example 3 with SuFormProperties

use of com.qlangtech.tis.extension.impl.SuFormProperties in project tis by qlangtech.

the class OfflineDatasourceAction method doGetDsTabsVals.

/**
 * 批量设置用,初始化数据库表
 *
 * @param context
 * @throws IOException
 */
public void doGetDsTabsVals(Context context) throws IOException {
    com.alibaba.fastjson.JSONObject body = this.parseJsonPost();
    com.alibaba.fastjson.JSONArray tabs = body.getJSONArray("tabs");
    if (tabs == null) {
        throw new IllegalArgumentException("initialize Tabs can not be null");
    }
    List<String> selectedTabs = tabs.stream().map((tab) -> (String) tab).collect(Collectors.toList());
    String pluginName = body.getString("name");
    boolean require = body.getBooleanValue("require");
    String extraParam = body.getString("extraParam");
    UploadPluginMeta pluginMeta = null;
    List<UploadPluginMeta> pluginMetas = UploadPluginMeta.parse(new String[] { pluginName + ":" + (require ? "require" : StringUtils.EMPTY) + "," + extraParam });
    for (UploadPluginMeta m : pluginMetas) {
        pluginMeta = m;
    }
    Objects.requireNonNull(pluginMeta, "pluginMeta can not be null");
    HeteroList<DataxReader> heteroList = pluginMeta.getHeteroList(this);
    List<DataxReader> readers = heteroList.getItems();
    Map<String, List<ColumnMetaData>> mapCols = null;
    List<ISelectedTab> allNewTabs = Lists.newArrayList();
    PluginFormProperties pluginFormPropertyTypes = null;
    Map<String, Object> bizResult = Maps.newHashMap();
    for (DataxReader reader : readers) {
        mapCols = selectedTabs.stream().collect(Collectors.toMap((tab) -> tab, (tab) -> {
            return reader.getTableMetadata(tab);
        }));
        if (MapUtils.isEmpty(mapCols)) {
            throw new IllegalStateException("mapCols can not be empty");
        }
        pluginFormPropertyTypes = reader.getDescriptor().getPluginFormPropertyTypes(pluginMeta.getSubFormFilter());
        for (Map.Entry<String, List<ColumnMetaData>> tab2cols : mapCols.entrySet()) {
            SuFormProperties.setSuFormGetterContext(reader, pluginMeta, tab2cols.getKey());
            allNewTabs.add(createNewSelectedTab(pluginFormPropertyTypes, tab2cols));
        }
        DescriptorsJSON desc2Json = new DescriptorsJSON(reader.getDescriptor());
        bizResult.put("subformDescriptor", desc2Json.getDescriptorsJSON(pluginMeta.getSubFormFilter()));
        break;
    }
    Objects.requireNonNull(pluginFormPropertyTypes, "pluginFormPropertyTypes can not be null");
    if (allNewTabs.size() < 1) {
        throw new IllegalStateException("allNewTabs size can not small than 1");
    }
    bizResult.put("tabVals", pluginFormPropertyTypes.accept(new PluginFormProperties.IVisitor() {

        @Override
        public com.alibaba.fastjson.JSONObject visit(SuFormProperties props) {
            return props.createSubFormVals(allNewTabs.stream().map((t) -> (IdentityName) t).collect(Collectors.toList()));
        }
    }));
    this.setBizResult(context, bizResult);
}
Also used : WorkFlow(com.qlangtech.tis.workflow.pojo.WorkFlow) StringUtils(org.apache.commons.lang.StringUtils) ERRules.$(com.qlangtech.tis.sql.parser.er.ERRules.$) SqlTaskNode(com.qlangtech.tis.sql.parser.SqlTaskNode) JoinRule(com.qlangtech.tis.git.GitUtils.JoinRule) TIS(com.qlangtech.tis.TIS) WorkFlowCriteria(com.qlangtech.tis.workflow.pojo.WorkFlowCriteria) Autowired(org.springframework.beans.factory.annotation.Autowired) Option(com.qlangtech.tis.manage.common.Option) DbScope(com.qlangtech.tis.offline.DbScope) DescriptorsJSON(com.qlangtech.tis.util.DescriptorsJSON) IFieldErrorHandler(com.qlangtech.tis.runtime.module.misc.IFieldErrorHandler) JSONObject(org.json.JSONObject) Matcher(java.util.regex.Matcher) DescriptorExtensionList(com.qlangtech.tis.extension.DescriptorExtensionList) PermissionConstant(com.qlangtech.tis.manage.PermissionConstant) FullbuildPhase(com.qlangtech.tis.assemble.FullbuildPhase) IPluginStore(com.qlangtech.tis.plugin.IPluginStore) PluginFormProperties(com.qlangtech.tis.extension.PluginFormProperties) PostParam(com.qlangtech.tis.manage.common.HttpUtils.PostParam) Validator(com.qlangtech.tis.plugin.annotation.Validator) GitRepositoryCommitPojo(com.qlangtech.tis.offline.pojo.GitRepositoryCommitPojo) DelegateControl4JsonPostMsgHandler(com.qlangtech.tis.runtime.module.misc.impl.DelegateControl4JsonPostMsgHandler) HeteroList(com.qlangtech.tis.util.HeteroList) Descriptor(com.qlangtech.tis.extension.Descriptor) TabCardinality(com.qlangtech.tis.sql.parser.er.TabCardinality) Collectors(java.util.stream.Collectors) name.fraser.neil.plaintext.diff_match_patch(name.fraser.neil.plaintext.diff_match_patch) IFullBuildContext(com.qlangtech.tis.fullbuild.IFullBuildContext) IOUtils(org.apache.commons.io.IOUtils) DataxReader(com.qlangtech.tis.datax.impl.DataxReader) IWorkFlowDAO(com.qlangtech.tis.workflow.dao.IWorkFlowDAO) IControlMsgHandler(com.qlangtech.tis.runtime.module.misc.IControlMsgHandler) TableRelation(com.qlangtech.tis.sql.parser.er.TableRelation) DataxAction(com.qlangtech.tis.coredefine.module.action.DataxAction) SqlDataFlowTopology(com.qlangtech.tis.sql.parser.SqlTaskNodeMeta.SqlDataFlowTopology) DBConfigSuit(com.qlangtech.tis.db.parser.DBConfigSuit) Pattern(java.util.regex.Pattern) SuFormProperties(com.qlangtech.tis.extension.impl.SuFormProperties) Types(java.sql.Types) Pager(com.koubei.web.tag.pager.Pager) java.util(java.util) Func(com.qlangtech.tis.manage.spring.aop.Func) UploadPluginMeta(com.qlangtech.tis.util.UploadPluginMeta) Context(com.alibaba.citrus.turbine.Context) TISDb(com.qlangtech.tis.offline.pojo.TISDb) JsonUtil(com.qlangtech.tis.trigger.util.JsonUtil) Lists(com.google.common.collect.Lists) PropertyType(com.qlangtech.tis.extension.impl.PropertyType) DatasourceTable(com.qlangtech.tis.workflow.pojo.DatasourceTable) CollectionUtils(org.apache.commons.collections.CollectionUtils) GitUtils(com.qlangtech.tis.git.GitUtils) OfflineManager(com.qlangtech.tis.offline.module.manager.impl.OfflineManager) FormFieldType(com.qlangtech.tis.plugin.annotation.FormFieldType) com.qlangtech.tis.sql.parser.meta(com.qlangtech.tis.sql.parser.meta) WorkflowPojo(com.qlangtech.tis.offline.pojo.WorkflowPojo) IWorkflowDAOFacade(com.qlangtech.tis.workflow.dao.IWorkflowDAOFacade) MapUtils(org.apache.commons.collections.MapUtils) IdentityName(com.qlangtech.tis.plugin.IdentityName) JSONTokener(org.json.JSONTokener) com.qlangtech.tis.plugin.ds(com.qlangtech.tis.plugin.ds) FileUtils(org.apache.commons.io.FileUtils) IOException(java.io.IOException) Maps(com.google.common.collect.Maps) File(java.io.File) TisSqlFormatException(com.qlangtech.tis.sql.parser.exception.TisSqlFormatException) JSON(com.alibaba.fastjson.JSON) ERRules(com.qlangtech.tis.sql.parser.er.ERRules) BasicModule(com.qlangtech.tis.runtime.module.action.BasicModule) AppDomainInfo(com.qlangtech.tis.manage.common.AppDomainInfo) CoreAction(com.qlangtech.tis.coredefine.module.action.CoreAction) Assert(com.qlangtech.tis.common.utils.Assert) SqlTaskNodeMeta(com.qlangtech.tis.sql.parser.SqlTaskNodeMeta) IUser(com.qlangtech.tis.manage.common.IUser) PrimaryTableMeta(com.qlangtech.tis.sql.parser.er.PrimaryTableMeta) JSONArray(org.json.JSONArray) PluginDescMeta(com.qlangtech.tis.coredefine.module.action.PluginDescMeta) DescriptorExtensionList(com.qlangtech.tis.extension.DescriptorExtensionList) HeteroList(com.qlangtech.tis.util.HeteroList) SuFormProperties(com.qlangtech.tis.extension.impl.SuFormProperties) UploadPluginMeta(com.qlangtech.tis.util.UploadPluginMeta) DataxReader(com.qlangtech.tis.datax.impl.DataxReader) PluginFormProperties(com.qlangtech.tis.extension.PluginFormProperties) DescriptorsJSON(com.qlangtech.tis.util.DescriptorsJSON) JSONObject(org.json.JSONObject)

Example 4 with SuFormProperties

use of com.qlangtech.tis.extension.impl.SuFormProperties in project tis by qlangtech.

the class OfflineDatasourceAction method createNewSelectedTab.

/**
 * 通过表名和列创建新tab实例,如果SelectedTab对象中有其他字段但是没有设置默认值,创建过程中就会出错
 *
 * @param pluginFormPropertyTypes
 * @param tab2cols
 * @return
 */
private ISelectedTab createNewSelectedTab(PluginFormProperties pluginFormPropertyTypes, Map.Entry<String, List<ColumnMetaData>> tab2cols) {
    return pluginFormPropertyTypes.accept(new PluginFormProperties.IVisitor() {

        @Override
        public ISelectedTab visit(SuFormProperties props) {
            // try {
            // } catch (Exception e) {
            // throw new RuntimeException("create subform,table:" + tab2cols.getKey()
            // + ",cols size:" + tab2cols.getValue().size(), e);
            // }
            ISelectedTab subForm = props.newSubDetailed();
            PropertyType pp = null;
            ppDftValGetter: for (Map.Entry<String, PropertyType> pentry : props.getKVTuples()) {
                pp = pentry.getValue();
                if (pp.isIdentity()) {
                    pp.setVal(subForm, tab2cols.getKey());
                    continue;
                }
                if (pp.formField.type() == FormFieldType.MULTI_SELECTABLE) {
                    pp.setVal(subForm, tab2cols.getValue().stream().map((c) -> c.getName()).collect(Collectors.toList()));
                    continue ppDftValGetter;
                }
                if (pp.isInputRequired()) {
                    if (StringUtils.isNotEmpty(pp.dftVal())) {
                        if (pp.isDescribable()) {
                            List<? extends Descriptor> descriptors = pp.getApplicableDescriptors();
                            for (Descriptor desc : descriptors) {
                                if (StringUtils.equals(pp.dftVal(), desc.getDisplayName())) {
                                    // desc.getPluginFormPropertyTypes();
                                    pp.setVal(subForm, desc.newInstance(null, Collections.emptyMap(), Optional.empty()).instance);
                                    continue ppDftValGetter;
                                }
                            }
                        } else {
                            pp.setVal(subForm, pp.dftVal());
                            continue ppDftValGetter;
                        }
                    } else {
                        // pp.getEnumConstants()
                        FormFieldType fieldType = pp.formField.type();
                        if (fieldType == FormFieldType.SELECTABLE || fieldType == FormFieldType.ENUM) {
                            Object enumPp = pp.getExtraProps().get(Descriptor.KEY_ENUM_PROP);
                            com.alibaba.fastjson.JSONArray enums = null;
                            if (enumPp instanceof com.alibaba.fastjson.JSONArray) {
                                enums = (com.alibaba.fastjson.JSONArray) enumPp;
                            } else if (enumPp instanceof JsonUtil.UnCacheString) {
                                enums = ((JsonUtil.UnCacheString<com.alibaba.fastjson.JSONArray>) enumPp).getValue();
                            } else {
                                throw new IllegalStateException("unsupport type:" + pp.getClass().getName());
                            }
                            for (int i = 0; i < enums.size(); i++) {
                                com.alibaba.fastjson.JSONObject opt = enums.getJSONObject(i);
                                pp.setVal(subForm, opt.get(Option.KEY_VALUE));
                                continue ppDftValGetter;
                            }
                        }
                    }
                    throw new IllegalStateException("have not prepare for table:" + tab2cols.getKey() + " creating,prop name:'" + pentry.getKey() + "',subform class:" + subForm.getClass().getName());
                }
            }
            return subForm;
        }
    });
}
Also used : FormFieldType(com.qlangtech.tis.plugin.annotation.FormFieldType) JSONArray(org.json.JSONArray) PropertyType(com.qlangtech.tis.extension.impl.PropertyType) PluginFormProperties(com.qlangtech.tis.extension.PluginFormProperties) JsonUtil(com.qlangtech.tis.trigger.util.JsonUtil) Descriptor(com.qlangtech.tis.extension.Descriptor) JSONObject(org.json.JSONObject) SuFormProperties(com.qlangtech.tis.extension.impl.SuFormProperties)

Example 5 with SuFormProperties

use of com.qlangtech.tis.extension.impl.SuFormProperties in project tis by qlangtech.

the class DescriptorsJSON method getDescriptorsJSON.

public JSONObject getDescriptorsJSON(Optional<IPropertyType.SubFormFilter> subFormFilter) {
    JSONArray attrs;
    String key;
    PropertyType val;
    JSONObject extraProps = null;
    // FormField fieldAnnot;
    JSONObject attrVal;
    JSONObject descriptors = new JSONObject();
    Map<String, Object> extractProps;
    // IPropertyType.SubFormFilter subFilter = null;
    PluginFormProperties pluginFormPropertyTypes;
    for (Descriptor<T> d : this.descriptors) {
        pluginFormPropertyTypes = d.getPluginFormPropertyTypes(subFormFilter);
        JSONObject des = new JSONObject();
        pluginFormPropertyTypes.accept(new SubFormFieldVisitor(subFormFilter) {

            @Override
            public Void visit(SuFormProperties props) {
                JSONObject subForm = new JSONObject();
                subForm.put("fieldName", props.getSubFormFieldName());
                if (subFormFilter.isPresent()) {
                    IPropertyType.SubFormFilter filter = subFormFilter.get();
                    if (!filter.subformDetailView) {
                        des.put("subForm", true);
                        subForm.put("idList", props.getSubFormIdListGetter().build(filter));
                    }
                }
                des.put("subFormMeta", subForm);
                return null;
            }
        });
        des.put(KEY_EXTEND_POINT, d.getT().getName());
        this.setDescInfo(d, des);
        des.put("veriflable", d.overWriteValidateMethod);
        if (IdentityName.class.isAssignableFrom(d.clazz)) {
            des.put("pkField", d.getIdentityField().displayName);
        }
        extractProps = d.getExtractProps();
        if (!extractProps.isEmpty()) {
            des.put("extractProps", extractProps);
        }
        attrs = new JSONArray();
        ArrayList<Map.Entry<String, PropertyType>> entries = Lists.newArrayList(pluginFormPropertyTypes.getKVTuples());
        entries.sort(((o1, o2) -> o1.getValue().ordinal() - o2.getValue().ordinal()));
        for (Map.Entry<String, PropertyType> pp : entries) {
            key = pp.getKey();
            val = pp.getValue();
            // fieldAnnot = val.getFormField();
            attrVal = new JSONObject();
            attrVal.put("key", key);
            // 是否是主键
            attrVal.put("pk", val.isIdentity());
            attrVal.put("describable", val.isDescribable());
            attrVal.put("type", val.typeIdentity());
            attrVal.put("required", val.isInputRequired());
            attrVal.put("ord", val.ordinal());
            extraProps = val.getExtraProps();
            if (extraProps != null) {
                // 额外属性
                attrVal.put("eprops", extraProps);
            }
            if (val.typeIdentity() == FormFieldType.SELECTABLE.getIdentity()) {
                attrVal.put("options", getSelectOptions(d, val, key));
            }
            if (val.isDescribable()) {
                DescriptorsJSON des2Json = new DescriptorsJSON(val.getApplicableDescriptors());
                attrVal.put("descriptors", des2Json.getDescriptorsJSON());
            }
            // attrs.put(attrVal);
            attrs.add(attrVal);
        }
        // 对象拥有的属性
        des.put("attrs", attrs);
        // processor.process(attrs.keySet(), d);
        descriptors.put(d.getId(), des);
    }
    return descriptors;
}
Also used : StringUtils(org.apache.commons.lang.StringUtils) java.util(java.util) Descriptor(com.qlangtech.tis.extension.Descriptor) IdentityName(com.qlangtech.tis.plugin.IdentityName) JSONArray(com.alibaba.fastjson.JSONArray) Config(com.qlangtech.tis.manage.common.Config) Lists(com.google.common.collect.Lists) PropertyType(com.qlangtech.tis.extension.impl.PropertyType) JSONObject(com.alibaba.fastjson.JSONObject) IPropertyType(com.qlangtech.tis.extension.IPropertyType) SuFormProperties(com.qlangtech.tis.extension.impl.SuFormProperties) Describable(com.qlangtech.tis.extension.Describable) PluginFormProperties(com.qlangtech.tis.extension.PluginFormProperties) FormFieldType(com.qlangtech.tis.plugin.annotation.FormFieldType) JSONArray(com.alibaba.fastjson.JSONArray) PropertyType(com.qlangtech.tis.extension.impl.PropertyType) IPropertyType(com.qlangtech.tis.extension.IPropertyType) PluginFormProperties(com.qlangtech.tis.extension.PluginFormProperties) JSONObject(com.alibaba.fastjson.JSONObject) JSONObject(com.alibaba.fastjson.JSONObject) SuFormProperties(com.qlangtech.tis.extension.impl.SuFormProperties)

Aggregations

SuFormProperties (com.qlangtech.tis.extension.impl.SuFormProperties)7 Descriptor (com.qlangtech.tis.extension.Descriptor)6 PluginFormProperties (com.qlangtech.tis.extension.PluginFormProperties)6 Lists (com.google.common.collect.Lists)4 DataxReader (com.qlangtech.tis.datax.impl.DataxReader)4 PropertyType (com.qlangtech.tis.extension.impl.PropertyType)4 java.util (java.util)4 TIS (com.qlangtech.tis.TIS)3 Describable (com.qlangtech.tis.extension.Describable)3 IPropertyType (com.qlangtech.tis.extension.IPropertyType)3 FormFieldType (com.qlangtech.tis.plugin.annotation.FormFieldType)3 StringUtils (org.apache.commons.lang.StringUtils)3 Context (com.alibaba.citrus.turbine.Context)2 Option (com.qlangtech.tis.manage.common.Option)2 DbScope (com.qlangtech.tis.offline.DbScope)2 IdentityName (com.qlangtech.tis.plugin.IdentityName)2 JsonUtil (com.qlangtech.tis.trigger.util.JsonUtil)2 IWorkflowDAOFacade (com.qlangtech.tis.workflow.dao.IWorkflowDAOFacade)2 File (java.io.File)2 Collectors (java.util.stream.Collectors)2