Search in sources :

Example 1 with PluginStore

use of com.qlangtech.tis.plugin.PluginStore 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 PluginStore

use of com.qlangtech.tis.plugin.PluginStore in project plugins by qlangtech.

the class TestHdfsFileSystemFactory method testCreate.

public void testCreate() {
    PluginStore pluginStore = TIS.getPluginStore(FileSystemFactory.class);
    assertNotNull(pluginStore);
    Describable<FileSystemFactory> plugin = pluginStore.getPlugin();
    assertNotNull(plugin);
    FileSystemFactory fsFactory = (FileSystemFactory) plugin;
    ITISFileSystem fileSystem = fsFactory.getFileSystem();
    List<IPathInfo> paths = fileSystem.listChildren(fileSystem.getPath("/"));
    for (IPathInfo i : paths) {
        System.out.println(i.getName());
    }
// plugin.
// 
// assertTrue("real class:" + plugin.getClass().getName(), plugin instanceof HdfsFileSystemFactory);
// HdfsFileSystemFactory fsFactory = (HdfsFileSystemFactory) plugin;
// ITISFileSystem fileSystem = fsFactory.getFileSystem();
// List<IPathInfo> paths = fileSystem.listChildren(fileSystem.getPath(fsFactory.getRootDir() + "/"));
// for (IPathInfo i : paths) {
// System.out.println(i.getName());
// }
}
Also used : PluginStore(com.qlangtech.tis.plugin.PluginStore) IPathInfo(com.qlangtech.tis.fs.IPathInfo) ITISFileSystem(com.qlangtech.tis.fs.ITISFileSystem) FileSystemFactory(com.qlangtech.tis.offline.FileSystemFactory)

Aggregations

PluginStore (com.qlangtech.tis.plugin.PluginStore)2 Lists (com.google.common.collect.Lists)1 TIS (com.qlangtech.tis.TIS)1 Public (com.qlangtech.tis.annotation.Public)1 IDataXPluginMeta (com.qlangtech.tis.datax.IDataXPluginMeta)1 IDataxReader (com.qlangtech.tis.datax.IDataxReader)1 Describable (com.qlangtech.tis.extension.Describable)1 Descriptor (com.qlangtech.tis.extension.Descriptor)1 PluginFormProperties (com.qlangtech.tis.extension.PluginFormProperties)1 SuFormProperties (com.qlangtech.tis.extension.impl.SuFormProperties)1 IPathInfo (com.qlangtech.tis.fs.IPathInfo)1 ITISFileSystem (com.qlangtech.tis.fs.ITISFileSystem)1 FileSystemFactory (com.qlangtech.tis.offline.FileSystemFactory)1 IPluginStore (com.qlangtech.tis.plugin.IPluginStore)1 KeyedPluginStore (com.qlangtech.tis.plugin.KeyedPluginStore)1 IPluginContext (com.qlangtech.tis.util.IPluginContext)1 java.util (java.util)1 StringUtils (org.apache.commons.lang.StringUtils)1