6 changed files with 294 additions and 1 deletions
@ -0,0 +1,64 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<WorkBook xmlVersion="20170720" releaseVersion="10.0.0"> |
||||||
|
<TableDataMap> |
||||||
|
<TableData name="ds1" class="com.fr.data.impl.DBTableData"> |
||||||
|
<Parameters/> |
||||||
|
<Attributes share="true" maxMemRowCount="-1"/> |
||||||
|
<Connection class="com.fr.data.impl.NameDatabaseConnection"> |
||||||
|
<DatabaseName> |
||||||
|
<![CDATA[FineDB]]></DatabaseName> |
||||||
|
</Connection> |
||||||
|
<Query> |
||||||
|
<![CDATA[SELECT * FROM Demo]]></Query> |
||||||
|
<PageQuery> |
||||||
|
<![CDATA[]]></PageQuery> |
||||||
|
</TableData> |
||||||
|
</TableDataMap> |
||||||
|
<Report class="com.fr.report.worksheet.WorkSheet" name="sheet1"> |
||||||
|
<ReportPageAttr> |
||||||
|
<HR/> |
||||||
|
<FR/> |
||||||
|
<HC/> |
||||||
|
<FC/> |
||||||
|
</ReportPageAttr> |
||||||
|
<ColumnPrivilegeControl/> |
||||||
|
<RowPrivilegeControl/> |
||||||
|
<RowHeight defaultValue="723900"> |
||||||
|
<![CDATA[723900,723900,723900,723900,723900,723900,723900,723900,723900,723900,723900,723900,723900,723900,723900,723900,723900,723900,723900,723900,723900,723900,723900,723900,723900,723900,723900,723900,723900,723900,723900,723900,723900,723900,723900,723900,723900,723900,723900,723900,723900,723900,723900,723900,723900,723900,723900,723900,723900,723900,723900]]></RowHeight> |
||||||
|
<ColumnWidth defaultValue="2743200"> |
||||||
|
<![CDATA[2743200,2743200,2743200,2743200,2743200,2743200,2743200,2743200,2743200,2743200,2743200,2743200,2743200,2743200,2743200,2743200,2743200,2743200,2743200,2743200,2743200]]></ColumnWidth> |
||||||
|
<CellElementList> |
||||||
|
<C c="0" r="0"> |
||||||
|
<O t="DSColumn"> |
||||||
|
<Attributes dsName="ds1" columnName="key"/> |
||||||
|
<Complex/> |
||||||
|
<RG class="com.fr.report.cell.cellattr.core.group.FunctionGrouper"/> |
||||||
|
<Parameters/> |
||||||
|
</O> |
||||||
|
<PrivilegeControl/> |
||||||
|
<Expand dir="0"/> |
||||||
|
</C> |
||||||
|
</CellElementList> |
||||||
|
<ReportAttrSet> |
||||||
|
<ReportSettings headerHeight="0" footerHeight="0"> |
||||||
|
<PaperSetting/> |
||||||
|
<Background name="ColorBackground" color="-1"/> |
||||||
|
</ReportSettings> |
||||||
|
</ReportAttrSet> |
||||||
|
<PrivilegeControl/> |
||||||
|
</Report> |
||||||
|
<ReportParameterAttr> |
||||||
|
<Attributes showWindow="true" delayPlaying="true" windowPosition="1" align="0" useParamsTemplate="true" currentIndex="0"/> |
||||||
|
<PWTitle> |
||||||
|
<![CDATA[参数]]></PWTitle> |
||||||
|
</ReportParameterAttr> |
||||||
|
<StyleList/> |
||||||
|
<DesignerVersion DesignerVersion="KAA"/> |
||||||
|
<PreviewType PreviewType="0"/> |
||||||
|
<TemplateCloudInfoAttrMark class="com.fr.plugin.cloud.analytics.attr.TemplateInfoAttrMark" pluginID="com.fr.plugin.cloud.analytics.v10" plugin-version="2.1.0.20210629"> |
||||||
|
<TemplateCloudInfoAttrMark createTime="1625626258463"/> |
||||||
|
</TemplateCloudInfoAttrMark> |
||||||
|
<TemplateIdAttMark class="com.fr.base.iofile.attr.TemplateIdAttrMark"> |
||||||
|
<TemplateIdAttMark TemplateId="34875c69-6420-433b-a311-bdccf493c803"/> |
||||||
|
</TemplateIdAttMark> |
||||||
|
</WorkBook> |
@ -1,3 +1,6 @@ |
|||||||
# demo-alternate-result-provider |
# demo-alternate-result-provider |
||||||
|
|
||||||
(共享数据集)缓存自定义接口 |
(共享数据集)缓存自定义接口\ |
||||||
|
demo生效后,用设计器打开附件模板,ds1的数据源随便选一个自己设计器的数据源链接。\ |
||||||
|
SQL不要改,就是 "SELECT * FROM Demo"。\ |
||||||
|
直接预览,会显示Key = Demo 的数据集结果(数据集必须是共享数据集)。(不需要数据源有Demo这张表) |
@ -0,0 +1,124 @@ |
|||||||
|
|
||||||
|
apply plugin: 'java' |
||||||
|
|
||||||
|
[compileJava,compileTestJava]*.options*.encoding = 'UTF-8' |
||||||
|
|
||||||
|
ext { |
||||||
|
/** |
||||||
|
* 项目中依赖的jar的路径 |
||||||
|
* 1.如果依赖的jar需要打包到zip中,放置在lib根目录下 |
||||||
|
* 2.如果依赖的jar仅仅是编译时需要,防止在lib下子目录下即可 |
||||||
|
*/ |
||||||
|
libPath = "$projectDir/../../webroot/WEB-INF/lib" |
||||||
|
|
||||||
|
/** |
||||||
|
* 是否对插件的class进行加密保护,防止反编译 |
||||||
|
*/ |
||||||
|
guard = false |
||||||
|
|
||||||
|
def pluginInfo = getPluginInfo() |
||||||
|
pluginPre = "fine-plugin" |
||||||
|
pluginName = pluginInfo.id |
||||||
|
pluginVersion = pluginInfo.version |
||||||
|
|
||||||
|
outputPath = "$projectDir/../../webroot/WEB-INF/plugins/plugin-" + pluginName + "-1.0/classes" |
||||||
|
} |
||||||
|
|
||||||
|
group = 'com.fr.plugin' |
||||||
|
version = '10.0' |
||||||
|
sourceCompatibility = '8' |
||||||
|
|
||||||
|
sourceSets { |
||||||
|
main { |
||||||
|
java.outputDir = file(outputPath) |
||||||
|
output.resourcesDir = file(outputPath) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
ant.importBuild("encrypt.xml") |
||||||
|
//定义ant变量 |
||||||
|
ant.projectDir = projectDir |
||||||
|
ant.references["compile.classpath"] = ant.path { |
||||||
|
fileset(dir: libPath, includes: '**/*.jar') |
||||||
|
fileset(dir: ".",includes:"**/*.jar" ) |
||||||
|
} |
||||||
|
|
||||||
|
classes.dependsOn('clean') |
||||||
|
|
||||||
|
task copyFiles(type: Copy,dependsOn: 'classes'){ |
||||||
|
from outputPath |
||||||
|
into "$projectDir/classes" |
||||||
|
} |
||||||
|
|
||||||
|
task preJar(type:Copy,dependsOn: guard ? 'compile_encrypt_javas' : 'compile_plain_javas'){ |
||||||
|
from "$projectDir/classes" |
||||||
|
into "$projectDir/transform-classes" |
||||||
|
include "**/*.*" |
||||||
|
} |
||||||
|
jar.dependsOn("preJar") |
||||||
|
|
||||||
|
task makeJar(type: Jar,dependsOn: preJar){ |
||||||
|
from fileTree(dir: "$projectDir/transform-classes") |
||||||
|
baseName pluginPre |
||||||
|
appendix pluginName |
||||||
|
version pluginVersion |
||||||
|
destinationDir = file("$buildDir/libs") |
||||||
|
|
||||||
|
doLast(){ |
||||||
|
delete file("$projectDir/classes") |
||||||
|
delete file("$projectDir/transform-classes") |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
task copyFile(type: Copy,dependsOn: ["makeJar"]){ |
||||||
|
from "$buildDir/libs" |
||||||
|
from("$projectDir/lib") { |
||||||
|
include "*.jar" |
||||||
|
} |
||||||
|
from "$projectDir/plugin.xml" |
||||||
|
into file("$buildDir/temp/plugin") |
||||||
|
} |
||||||
|
|
||||||
|
task zip(type:Zip,dependsOn:["copyFile"]){ |
||||||
|
from "$buildDir/temp/plugin" |
||||||
|
destinationDir file("$buildDir/install") |
||||||
|
baseName pluginPre |
||||||
|
appendix pluginName |
||||||
|
version pluginVersion |
||||||
|
} |
||||||
|
|
||||||
|
//控制build时包含哪些文件,排除哪些文件 |
||||||
|
processResources { |
||||||
|
// exclude everything |
||||||
|
// 用*.css没效果 |
||||||
|
// exclude '**/*.css' |
||||||
|
// except this file |
||||||
|
// include 'xx.xml' |
||||||
|
} |
||||||
|
|
||||||
|
/*读取plugin.xml中的version*/ |
||||||
|
def getPluginInfo(){ |
||||||
|
def xmlFile = file("plugin.xml") |
||||||
|
if (!xmlFile.exists()) { |
||||||
|
return ["id":"none", "version":"1.0.0"] |
||||||
|
} |
||||||
|
def plugin = new XmlParser().parse(xmlFile) |
||||||
|
def version = plugin.version[0].text() |
||||||
|
def id = plugin.id[0].text() |
||||||
|
return ["id":id,"version":version] |
||||||
|
} |
||||||
|
|
||||||
|
repositories { |
||||||
|
mavenLocal() |
||||||
|
maven { |
||||||
|
url = uri('http://mvn.finedevelop.com/repository/maven-public/') |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
dependencies { |
||||||
|
//使用本地jar |
||||||
|
implementation fileTree(dir: 'lib', include: ['**/*.jar']) |
||||||
|
implementation fileTree(dir: libPath, include: ['**/*.jar']) |
||||||
|
} |
||||||
|
|
||||||
|
|
@ -0,0 +1,13 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?> |
||||||
|
<project> |
||||||
|
<target name="compile_encrypt_javas" depends="copyFiles"> |
||||||
|
<echo message="加密文件"/> |
||||||
|
<echo message="${projectDir}"/> |
||||||
|
<taskdef name="pretreatment" classname="com.fr.plugin.pack.PluginPretreatmentTask"> |
||||||
|
<classpath refid="compile.classpath"/> |
||||||
|
</taskdef> |
||||||
|
<pretreatment baseDir="${projectDir}"/> |
||||||
|
</target> |
||||||
|
<target name="compile_plain_javas" depends="copyFiles"> |
||||||
|
</target> |
||||||
|
</project> |
@ -0,0 +1,16 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?><plugin> |
||||||
|
<id>com.tptj.demo.hg.alternate.result.provider.v10</id> |
||||||
|
<name><![CDATA[ AlternateResultProvider ]]></name> |
||||||
|
<active>yes</active> |
||||||
|
<version>1.0</version> |
||||||
|
<env-version>10.0</env-version> |
||||||
|
<vendor>tptj</vendor> |
||||||
|
<jartime>2019-07-18</jartime> |
||||||
|
<description><![CDATA[ ]]></description> |
||||||
|
<change-notes><![CDATA[]]></change-notes> |
||||||
|
<main-package>com.tptj.demo.hg.alternate.result.provider</main-package> |
||||||
|
<function-recorder class="com.tptj.demo.hg.alternate.result.provider.Demo"/> |
||||||
|
<extra-core> |
||||||
|
<AlternateResultProvider class="com.tptj.demo.hg.alternate.result.provider.Demo"/> |
||||||
|
</extra-core> |
||||||
|
</plugin> |
@ -0,0 +1,73 @@ |
|||||||
|
package com.tptj.demo.hg.alternate.result.provider; |
||||||
|
|
||||||
|
import com.fr.data.AbstractDataModel; |
||||||
|
import com.fr.data.impl.QueryEntity; |
||||||
|
import com.fr.general.data.DataModel; |
||||||
|
import com.fr.general.data.TableDataException; |
||||||
|
import com.fr.intelli.record.Focus; |
||||||
|
import com.fr.log.FineLoggerFactory; |
||||||
|
import com.fr.measure.metric.DBMetric; |
||||||
|
import com.fr.record.analyzer.EnableMetrics; |
||||||
|
import com.fr.stable.fun.impl.AbstractAlternateResultProvider; |
||||||
|
|
||||||
|
import java.util.Iterator; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author 秃破天际 |
||||||
|
* @version 10.0 |
||||||
|
* Created by 秃破天际 on 2021/7/7 |
||||||
|
**/ |
||||||
|
@EnableMetrics |
||||||
|
public class Demo extends AbstractAlternateResultProvider<QueryEntity, DataModel> { |
||||||
|
@Override |
||||||
|
public QueryEntity[] matchedKeys(Object extraKey ) { |
||||||
|
return new QueryEntity[0]; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean accept( Class kClass, Class vClass ) { |
||||||
|
return QueryEntity.class.equals(kClass) && DataModel.class.equals(vClass); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
@Focus(id="com.tptj.demo.hg.alternate.result.provider.v10",text="AlternateResultProvider") |
||||||
|
public DataModel get(QueryEntity key) { |
||||||
|
if("SELECT * FROM Demo".equals( key.getSql() )){ |
||||||
|
return new AbstractDataModel(){ |
||||||
|
|
||||||
|
@Override |
||||||
|
public int getColumnCount() throws TableDataException { |
||||||
|
return 1; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String getColumnName(int colIdX) throws TableDataException { |
||||||
|
return "key"; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public int getRowCount() throws TableDataException { |
||||||
|
return 1; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Object getValueAt(int rowIdx, int colIdx) throws TableDataException { |
||||||
|
return "demo"; |
||||||
|
} |
||||||
|
|
||||||
|
}; |
||||||
|
} |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void put(QueryEntity key, DataModel value) { |
||||||
|
FineLoggerFactory.getLogger().info(""); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void remove(QueryEntity key) { |
||||||
|
FineLoggerFactory.getLogger().info(""); |
||||||
|
} |
||||||
|
|
||||||
|
} |
Loading…
Reference in new issue