Skip to content

Commit c8c94e6

Browse files
committed
AI package
1 parent 125167f commit c8c94e6

File tree

20 files changed

+854
-26
lines changed

20 files changed

+854
-26
lines changed

logicaldoc-core/src/main/java/com/logicaldoc/core/automation/Automation.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ public Automation(String logTag, Locale locale, long tenantId) {
142142
*
143143
* @return The complete dictionary to use
144144
*/
145-
@SuppressWarnings({ "rawtypes", "unchecked" })
146145
private Map<String, Object> prepareDictionary(Map<String, Object> clientDictionary) {
147146
if (clientDictionary == null)
148147
clientDictionary = new ConcurrentHashMap<>();
@@ -157,7 +156,7 @@ private Map<String, Object> prepareDictionary(Map<String, Object> clientDictiona
157156
String beanClassName = bd.getBeanClassName();
158157

159158
try {
160-
Class beanClass = Class.forName(beanClassName);
159+
Class<?> beanClass = Class.forName(beanClassName);
161160

162161
String key = beanClass.getSimpleName();
163162
AutomationDictionary annotation = (AutomationDictionary) beanClass

logicaldoc-gui/src/main/java/com/logicaldoc/gui/common/client/Menu.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,8 @@ public class Menu {
219219

220220
public static final long GOOGLE_CALENDAR = -2081;
221221

222+
public static final long ARTIFICIAL_INTELLIGENCE = 3000;
223+
222224
private static Set<Long> menus = new HashSet<>();
223225

224226
private Menu() {

logicaldoc-gui/src/main/java/com/logicaldoc/gui/frontend/client/administration/AdminMenu.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.logicaldoc.gui.common.client.Feature;
44
import com.logicaldoc.gui.common.client.Menu;
55
import com.logicaldoc.gui.common.client.i18n.I18N;
6+
import com.logicaldoc.gui.frontend.client.ai.AIMenu;
67
import com.logicaldoc.gui.frontend.client.impex.ImpexMenu;
78
import com.logicaldoc.gui.frontend.client.metadata.MetadataMenu;
89
import com.logicaldoc.gui.frontend.client.reports.ReportsMenu;
@@ -70,6 +71,12 @@ private AdminMenu() {
7071
addSection(toolsSection);
7172
}
7273

74+
if (Feature.visible(Feature.ARTIFICIAL_INTELLIGENCE) && Menu.enabled(Menu.ARTIFICIAL_INTELLIGENCE)) {
75+
SectionStackSection aiSection = new SectionStackSection(I18N.message("artificialintelligence"));
76+
aiSection.setExpanded(false);
77+
aiSection.addItem(new AIMenu());
78+
addSection(aiSection);
79+
}
7380
if (Menu.enabled(Menu.SETTINGS)) {
7481
SectionStackSection settingsSection = new SectionStackSection(I18N.message("settings"));
7582
settingsSection.setExpanded(false);
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package com.logicaldoc.gui.frontend.client.ai;
2+
3+
import com.logicaldoc.gui.common.client.i18n.I18N;
4+
import com.logicaldoc.gui.frontend.client.administration.AdminScreen;
5+
import com.smartgwt.client.types.Overflow;
6+
import com.smartgwt.client.widgets.Button;
7+
import com.smartgwt.client.widgets.layout.VLayout;
8+
9+
/**
10+
* This panel shows the administration of AI aspects
11+
*
12+
* @author Marco Meschieri - LogicalDOC
13+
* @since 9.2
14+
*/
15+
public class AIMenu extends VLayout {
16+
17+
public AIMenu() {
18+
setMargin(10);
19+
setMembersMargin(5);
20+
setOverflow(Overflow.AUTO);
21+
22+
addModelsButton();
23+
}
24+
25+
private void addModelsButton() {
26+
Button templates = new Button(I18N.message("models"));
27+
templates.setWidth100();
28+
templates.setHeight(25);
29+
templates.addClickHandler(templatesClick -> AdminScreen.get().setContent(new ModelsAndSamplersPanel()));
30+
addMember(templates);
31+
}
32+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
package com.logicaldoc.gui.frontend.client.ai;
2+
3+
import com.google.gwt.core.client.GWT;
4+
import com.google.gwt.user.client.rpc.RemoteService;
5+
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
6+
import com.google.gwt.user.client.rpc.ServiceDefTarget;
7+
import com.logicaldoc.gui.common.client.LDRpcRequestBuilder;
8+
import com.logicaldoc.gui.common.client.ServerException;
9+
import com.logicaldoc.gui.frontend.client.ai.sampler.GUISampler;
10+
11+
/**
12+
* The client side stub for the Artificial Intelligence Service. This service
13+
* gives all needed methods to handle templates.
14+
*
15+
* @author Marco Meschieri - LogicalDOC
16+
* @since 9.2
17+
*/
18+
@RemoteServiceRelativePath("ai")
19+
public interface AIService extends RemoteService {
20+
/**
21+
* Deletes a given sampler
22+
*
23+
* @param samplerId identifier of the sampler
24+
*
25+
* @throws ServerException an error happened in the server application
26+
*/
27+
public void deleteSampler(long samplerId) throws ServerException;
28+
29+
/**
30+
* Creates or updates a sampler
31+
*
32+
* @param sampler the sampler to save
33+
*
34+
* @return the saved sampler
35+
*
36+
* @throws ServerException an error happened in the server application
37+
*/
38+
public GUISampler saveSampler(GUISampler sampler) throws ServerException;
39+
40+
/**
41+
* Retrieves a sampler from the data layer
42+
*
43+
* @param samplerId identifier of the sampler
44+
*
45+
* @return the sampler
46+
*
47+
* @throws ServerException an error happened in the server application
48+
*/
49+
public GUISampler getSampler(long samplerId) throws ServerException;
50+
51+
public static class Instance {
52+
private static AIServiceAsync inst;
53+
54+
private Instance() {
55+
}
56+
57+
public static AIServiceAsync get() {
58+
if (inst == null) {
59+
inst = GWT.create(AIService.class);
60+
((ServiceDefTarget) inst).setRpcRequestBuilder(new LDRpcRequestBuilder());
61+
}
62+
return inst;
63+
}
64+
}
65+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.logicaldoc.gui.frontend.client.ai;
2+
3+
import com.google.gwt.user.client.rpc.AsyncCallback;
4+
import com.logicaldoc.gui.frontend.client.ai.sampler.GUISampler;
5+
6+
public interface AIServiceAsync {
7+
8+
void deleteSampler(long samplerId, AsyncCallback<Void> callback);
9+
10+
void saveSampler(GUISampler sampler, AsyncCallback<GUISampler> callback);
11+
12+
void getSampler(long samplerId, AsyncCallback<GUISampler> callback);
13+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.logicaldoc.gui.frontend.client.ai;
2+
3+
import com.logicaldoc.gui.common.client.i18n.I18N;
4+
import com.logicaldoc.gui.frontend.client.administration.AdminPanel;
5+
import com.logicaldoc.gui.frontend.client.ai.sampler.SamplersPanel;
6+
import com.logicaldoc.gui.frontend.client.metadata.template.TemplatesPanel;
7+
import com.smartgwt.client.widgets.tab.Tab;
8+
9+
/**
10+
* Panel showing the panels for handling AI models and samplers
11+
*
12+
* @author Marco Meschieri - LogicalDOC
13+
* @since 9.2
14+
*/
15+
public class ModelsAndSamplersPanel extends AdminPanel {
16+
public ModelsAndSamplersPanel() {
17+
super("templates");
18+
19+
body.setMembers(new TemplatesPanel());
20+
21+
Tab attributesTab = new Tab(I18N.message("samplers"));
22+
attributesTab.setPane(new SamplersPanel());
23+
24+
tabs.addTab(attributesTab);
25+
}
26+
}
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
package com.logicaldoc.gui.frontend.client.ai.sampler;
2+
3+
import java.util.ArrayList;
4+
import java.util.List;
5+
6+
import com.logicaldoc.gui.common.client.beans.GUIDocument;
7+
import com.logicaldoc.gui.common.client.beans.GUIExtensibleObject;
8+
import com.logicaldoc.gui.common.client.beans.GUIFolder;
9+
10+
/**
11+
* A GUI bean representing a sampler
12+
*
13+
* @author Marco Meschieri - LogicalDOC
14+
* @since 9.2
15+
*
16+
*/
17+
public class GUISampler extends GUIExtensibleObject {
18+
19+
private static final long serialVersionUID = 1L;
20+
21+
private String name;
22+
23+
private String label;
24+
25+
private String description;
26+
27+
private String type = "csv";
28+
29+
private long count = 0L;
30+
31+
private GUIDocument document;
32+
33+
private GUIFolder folder;
34+
35+
private List<GUISampler> samplers = new ArrayList<>();
36+
37+
private List<GUIExtensibleObject> source = new ArrayList<>();
38+
39+
private String categoryAttribute = null;
40+
41+
private String automation;
42+
43+
public String getName() {
44+
return name;
45+
}
46+
47+
public String getLabel() {
48+
return label;
49+
}
50+
51+
public String getDescription() {
52+
return description;
53+
}
54+
55+
public long getCount() {
56+
return count;
57+
}
58+
59+
public GUIDocument getDocument() {
60+
return document;
61+
}
62+
63+
public GUIFolder getFolder() {
64+
return folder;
65+
}
66+
67+
public List<GUISampler> getSamplers() {
68+
return samplers;
69+
}
70+
71+
public List<GUIExtensibleObject> getSource() {
72+
return source;
73+
}
74+
75+
public String getCategoryAttribute() {
76+
return categoryAttribute;
77+
}
78+
79+
public String getAutomation() {
80+
return automation;
81+
}
82+
83+
public void setName(String name) {
84+
this.name = name;
85+
}
86+
87+
public void setLabel(String label) {
88+
this.label = label;
89+
}
90+
91+
public void setDescription(String description) {
92+
this.description = description;
93+
}
94+
95+
public void setCount(long count) {
96+
this.count = count;
97+
}
98+
99+
public void setDocument(GUIDocument document) {
100+
this.document = document;
101+
}
102+
103+
public void setFolder(GUIFolder folder) {
104+
this.folder = folder;
105+
}
106+
107+
public void setSamplers(List<GUISampler> samplers) {
108+
this.samplers = samplers;
109+
}
110+
111+
public void setSource(List<GUIExtensibleObject> source) {
112+
this.source = source;
113+
}
114+
115+
public void setCategoryAttribute(String categoryAttribute) {
116+
this.categoryAttribute = categoryAttribute;
117+
}
118+
119+
public void setAutomation(String automation) {
120+
this.automation = automation;
121+
}
122+
123+
public String getType() {
124+
return type;
125+
}
126+
127+
public void setType(String type) {
128+
this.type = type;
129+
}
130+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package com.logicaldoc.gui.frontend.client.ai.sampler;
2+
3+
import com.smartgwt.client.data.DataSource;
4+
import com.smartgwt.client.data.fields.DataSourceDateTimeField;
5+
import com.smartgwt.client.data.fields.DataSourceTextField;
6+
7+
/**
8+
* Datasource to handle samplers grid lists. It is based on Xml parsing
9+
*
10+
* @author Marco Meschieri - LogicalDOC
11+
* @since 9.2
12+
*/
13+
public class SamplerDS extends DataSource {
14+
15+
public SamplerDS() {
16+
init("data/ai.xml?object=sampler");
17+
}
18+
19+
private void init(String url) {
20+
setRecordXPath("/list/sampler");
21+
22+
DataSourceTextField id = new DataSourceTextField("id");
23+
id.setPrimaryKey(true);
24+
id.setHidden(true);
25+
id.setRequired(true);
26+
27+
DataSourceTextField name = new DataSourceTextField("name");
28+
DataSourceTextField label = new DataSourceTextField("label");
29+
DataSourceDateTimeField creation = new DataSourceDateTimeField("creation");
30+
DataSourceTextField type = new DataSourceTextField("type");
31+
32+
setFields(id, name, label, type, creation);
33+
setClientOnly(true);
34+
35+
setDataURL(url);
36+
}
37+
}

0 commit comments

Comments
 (0)