Skip to content

Commit 9da76dc

Browse files
committed
new labels
1 parent f756ff1 commit 9da76dc

File tree

6 files changed

+159
-19
lines changed

6 files changed

+159
-19
lines changed

logicaldoc-gui/src/main/java/com/logicaldoc/gui/frontend/client/ai/AIService.java

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
package com.logicaldoc.gui.frontend.client.ai;
22

3+
import java.util.List;
4+
35
import com.google.gwt.core.client.GWT;
46
import com.google.gwt.user.client.rpc.RemoteService;
57
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
68
import com.google.gwt.user.client.rpc.ServiceDefTarget;
79
import com.logicaldoc.gui.common.client.LDRpcRequestBuilder;
810
import com.logicaldoc.gui.common.client.ServerException;
11+
import com.logicaldoc.gui.frontend.client.ai.model.GUIModel;
912
import com.logicaldoc.gui.frontend.client.ai.sampler.GUISampler;
1013

1114
/**
@@ -18,13 +21,13 @@
1821
@RemoteServiceRelativePath("ai")
1922
public interface AIService extends RemoteService {
2023
/**
21-
* Deletes a given sampler
24+
* Deletes some samplers
2225
*
23-
* @param samplerId identifier of the sampler
26+
* @param samplerIds identifiers of the samplers
2427
*
2528
* @throws ServerException an error happened in the server application
2629
*/
27-
public void deleteSampler(long samplerId) throws ServerException;
30+
public void deleteSamplers(List<Long> samplerIds) throws ServerException;
2831

2932
/**
3033
* Creates or updates a sampler
@@ -48,6 +51,37 @@ public interface AIService extends RemoteService {
4851
*/
4952
public GUISampler getSampler(long samplerId) throws ServerException;
5053

54+
/**
55+
* Deletes a a set of models
56+
*
57+
* @param modelIds identifiers of the models to delete
58+
*
59+
* @throws ServerException an error happened in the server application
60+
*/
61+
public void deleteModels(List<Long> modelIds) throws ServerException;
62+
63+
/**
64+
* Creates or updates a model
65+
*
66+
* @param model the model to save
67+
*
68+
* @return the saved model
69+
*
70+
* @throws ServerException an error happened in the server application
71+
*/
72+
public GUIModel saveModel(GUIModel model) throws ServerException;
73+
74+
/**
75+
* Retrieves a model from the data layer
76+
*
77+
* @param modelId identifier of the model
78+
*
79+
* @return the model
80+
*
81+
* @throws ServerException an error happened in the server application
82+
*/
83+
public GUIModel getModel(long modelId) throws ServerException;
84+
5185
public static class Instance {
5286
private static AIServiceAsync inst;
5387

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
11
package com.logicaldoc.gui.frontend.client.ai;
22

3+
import java.util.List;
4+
35
import com.google.gwt.user.client.rpc.AsyncCallback;
6+
import com.logicaldoc.gui.frontend.client.ai.model.GUIModel;
47
import com.logicaldoc.gui.frontend.client.ai.sampler.GUISampler;
58

69
public interface AIServiceAsync {
710

8-
void deleteSampler(long samplerId, AsyncCallback<Void> callback);
11+
void deleteSamplers(List<Long> samplerIds, AsyncCallback<Void> callback);
912

1013
void saveSampler(GUISampler sampler, AsyncCallback<GUISampler> callback);
1114

1215
void getSampler(long samplerId, AsyncCallback<GUISampler> callback);
16+
17+
void deleteModels(List<Long> modelIds, AsyncCallback<Void> callback);
18+
19+
void saveModel(GUIModel model, AsyncCallback<GUIModel> callback);
20+
21+
void getModel(long modelId, AsyncCallback<GUIModel> callback);
1322
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
package com.logicaldoc.gui.frontend.client.ai.model;
2+
3+
import java.io.Serializable;
4+
5+
/**
6+
* A GUI bean representing an AI model
7+
*
8+
* @author Marco Meschieri - LogicalDOC
9+
* @since 9.2
10+
*/
11+
public class GUIModel implements Serializable {
12+
13+
private static final long serialVersionUID = 1L;
14+
15+
private long id = 0;
16+
17+
private String name;
18+
19+
private String label;
20+
21+
private String description;
22+
23+
private String type = "neural";
24+
25+
public GUIModel(long id, String name) {
26+
super();
27+
this.id = id;
28+
this.name = name;
29+
}
30+
31+
public GUIModel() {
32+
super();
33+
}
34+
35+
public long getId() {
36+
return id;
37+
}
38+
39+
public String getName() {
40+
return name;
41+
}
42+
43+
public String getLabel() {
44+
return label;
45+
}
46+
47+
public String getDescription() {
48+
return description;
49+
}
50+
51+
public String getType() {
52+
return type;
53+
}
54+
55+
public void setId(long id) {
56+
this.id = id;
57+
}
58+
59+
public void setName(String name) {
60+
this.name = name;
61+
}
62+
63+
public void setLabel(String label) {
64+
this.label = label;
65+
}
66+
67+
public void setDescription(String description) {
68+
this.description = description;
69+
}
70+
71+
public void setType(String type) {
72+
this.type = type;
73+
}
74+
}

logicaldoc-gui/src/main/java/com/logicaldoc/gui/frontend/client/ai/sampler/SamplerProperties.java

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
*/
3434
public class SamplerProperties extends SamplerDetailsTab {
3535

36+
private static final String CSV = "csv";
37+
3638
private static final String ID = "id";
3739

3840
private static final String DECRIPTION = "decription";
@@ -81,7 +83,7 @@ private void refresh() {
8183
container.removeChild(form);
8284

8385
form = new DynamicForm();
84-
form.setNumCols(2);
86+
form.setNumCols(4);
8587
form.setTitleOrientation(TitleOrientation.TOP);
8688

8789
TextItem name = ItemFactory.newSimpleTextItem(NAME, sampler.getName());
@@ -91,22 +93,30 @@ private void refresh() {
9193
TextItem label = ItemFactory.newTextItem("label", sampler.getLabel());
9294
label.addChangedHandler(changedHandler);
9395

94-
TextAreaItem description = ItemFactory.newTextAreaItem("description", sampler.getDescription());
95-
description.addChangedHandler(changedHandler);
96-
9796
TextItem delimiter = ItemFactory.newSimpleTextItem("delimiter", sampler.getDelimiter());
9897
delimiter.addChangedHandler(changedHandler);
99-
delimiter.setRequired(true);
100-
delimiter.setWidth(50);
98+
delimiter.setWidth(30);
10199
delimiter.setLength(1);
102-
delimiter.setVisibleWhen(new AdvancedCriteria(TYPE, OperatorId.EQUALS, "csv"));
100+
delimiter.setVisibleWhen(new AdvancedCriteria(TYPE, OperatorId.EQUALS, CSV));
101+
delimiter.setRequiredWhen(new AdvancedCriteria(TYPE, OperatorId.EQUALS, CSV));
103102

104103
TextItem quote = ItemFactory.newSimpleTextItem("quote", sampler.getQuote());
105104
quote.addChangedHandler(changedHandler);
106-
quote.setRequired(true);
107-
quote.setWidth(50);
105+
quote.setWidth(30);
108106
quote.setLength(1);
109-
quote.setVisibleWhen(new AdvancedCriteria(TYPE, OperatorId.EQUALS, "csv"));
107+
quote.setVisibleWhen(new AdvancedCriteria(TYPE, OperatorId.EQUALS, CSV));
108+
quote.setRequiredWhen(new AdvancedCriteria(TYPE, OperatorId.EQUALS, CSV));
109+
110+
TextAreaItem description = ItemFactory.newTextAreaItem("description", sampler.getDescription());
111+
description.addChangedHandler(changedHandler);
112+
description.setColSpan(4);
113+
description.setWidth("*");
114+
115+
TextAreaItem automation = ItemFactory.newTextAreaItemForAutomation("automation", sampler.getAutomation(), changedHandler, false);
116+
automation.addChangedHandler(changedHandler);
117+
automation.setColSpan(4);
118+
automation.setWidth("*");
119+
automation.setVisibleWhen(new AdvancedCriteria(TYPE, OperatorId.EQUALS, METADATA));
110120

111121
SelectItem type = ItemFactory.newSelectItem(TYPE);
112122
type.setOptionDataSource(new SamplerTypeDS());
@@ -134,7 +144,12 @@ private void refresh() {
134144
documentSelector
135145
.setVisibleWhen(new AdvancedCriteria(TYPE, OperatorId.NOT_IN_SET, new String[] { METADATA, "chain" }));
136146

137-
form.setItems(id, name, type, typeValue, label, delimiter, quote, folderSelector, documentSelector);
147+
TextItem categoryAttribute = ItemFactory.newTextItem("categoryattribute", sampler.getCategoryAttribute());
148+
categoryAttribute.addChangedHandler(changedHandler);
149+
categoryAttribute.setRequiredWhen(new AdvancedCriteria(TYPE, OperatorId.EQUALS, METADATA));
150+
categoryAttribute.setVisibleWhen(new AdvancedCriteria(TYPE, OperatorId.EQUALS, METADATA));
151+
152+
form.setItems(id, name, type, typeValue, label, delimiter, quote, folderSelector, documentSelector, categoryAttribute, automation, description);
138153

139154
container.setMembersMargin(3);
140155
container.addMember(form);

logicaldoc-gui/src/main/java/com/logicaldoc/gui/frontend/client/ai/sampler/SamplersPanel.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package com.logicaldoc.gui.frontend.client.ai.sampler;
22

3+
import java.util.ArrayList;
4+
import java.util.List;
5+
36
import com.logicaldoc.gui.common.client.DefaultAsyncCallback;
47
import com.logicaldoc.gui.common.client.grid.IdListGridField;
58
import com.logicaldoc.gui.common.client.grid.RefreshableListGrid;
@@ -147,14 +150,16 @@ public void onSuccess(GUISampler sampler) {
147150
private void showContextMenu() {
148151
Menu contextMenu = new Menu();
149152

150-
final ListGridRecord rec = list.getSelectedRecord();
151-
final long id = rec.getAttributeAsLong("id");
153+
final ListGridRecord[] selection = list.getSelectedRecords();
154+
List<Long> ids = new ArrayList<>();
155+
for (ListGridRecord rec : selection)
156+
ids.add(rec.getAttributeAsLong("id"));
152157

153158
MenuItem delete = new MenuItem();
154159
delete.setTitle(I18N.message("ddelete"));
155160
delete.addClickHandler(event -> LD.ask(I18N.message("question"), I18N.message("confirmdelete"), confirm -> {
156161
if (Boolean.TRUE.equals(confirm)) {
157-
AIService.Instance.get().deleteSampler(id, new DefaultAsyncCallback<>() {
162+
AIService.Instance.get().deleteSamplers(ids, new DefaultAsyncCallback<>() {
158163
@Override
159164
public void onSuccess(Void result) {
160165
list.removeSelectedData();

logicaldoc-i18n/src/main/resources/i18n/messages.properties

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2652,4 +2652,7 @@ selecttasampler = Select a sampler
26522652
samplers = Samplers
26532653
addsampler = Add sampler
26542654
chain = Chain
2655-
sampler = Sampler
2655+
sampler = Sampler
2656+
quote = Quote
2657+
delimiter = Delimiter
2658+
categoryattribute = Category attribute

0 commit comments

Comments
 (0)