-
Notifications
You must be signed in to change notification settings - Fork 477
/
SchemasPlaceEvent.java
131 lines (106 loc) · 4.14 KB
/
SchemasPlaceEvent.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/*
* Copyright 2014-2016 CyberVision, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.kaaproject.kaa.server.admin.client.mvp.place;
import com.google.gwt.place.shared.PlaceTokenizer;
import com.google.gwt.view.client.HasData;
import com.google.web.bindery.event.shared.EventBus;
import org.kaaproject.kaa.server.admin.client.util.Utils;
import org.kaaproject.kaa.server.admin.shared.schema.EventClassViewDto;
import java.util.ArrayList;
import java.util.List;
public class SchemasPlaceEvent extends TreePlace {
protected String ecfId;
protected String ecfVersionId;
protected int ecfVersion;
protected static List<EventClassViewDto> eventClassDtoList;
private SchemasPlaceDataProvider dataProvider;
public SchemasPlaceEvent(String ecfId, String ecfVersionId, int ecfVersion) {
this.ecfId = ecfId;
this.ecfVersionId = ecfVersionId;
this.ecfVersion = ecfVersion;
}
public SchemasPlaceEvent(String ecfId, String ecfVersionId, int ecfVersion, List<EventClassViewDto> eventClassDtoList) {
this.ecfId = ecfId;
this.ecfVersionId = ecfVersionId;
this.ecfVersion = ecfVersion;
this.eventClassDtoList = eventClassDtoList;
}
public void addEventClassViewDto(EventClassViewDto eventClassViewDto) {
if (eventClassDtoList == null) {
this.eventClassDtoList = new ArrayList<>();
}
eventClassDtoList.add(eventClassViewDto);
}
public static List<EventClassViewDto> getEventClassDtoList() {
return eventClassDtoList;
}
public void setEventClassDtoList(List<EventClassViewDto> eventClassDtoList) {
this.eventClassDtoList = eventClassDtoList;
}
public String getEcfId() {
return ecfId;
}
public String getEcfVersionId() {
return ecfVersionId;
}
public int getEcfVersion() {
return ecfVersion;
}
@Override
public String getName() {
return Utils.constants.versions();
}
public static abstract class Tokenizer<P extends SchemasPlaceEvent> implements PlaceTokenizer<P>, PlaceConstants {
@Override
public P getPlace(String token) {
PlaceParams.paramsFromToken(token);
return getPlaceImpl(PlaceParams.getParam(ECF_ID), PlaceParams.getParam(ECF_VERSION_ID), PlaceParams.getIntParam(ECF_VERSION));
}
protected abstract P getPlaceImpl(String ecfId, String ecfVersionId, int ecfVersion);
@Override
public String getToken(P place) {
PlaceParams.clear();
PlaceParams.putParam(ECF_ID, place.getEcfId());
PlaceParams.putParam(ECF_VERSION_ID, place.getEcfVersionId());
PlaceParams.putIntParam(ECF_VERSION, place.getEcfVersion());
return PlaceParams.generateToken();
}
}
@Override
public boolean isLeaf() {
return false;
}
@Override
public TreePlaceDataProvider getDataProvider(EventBus eventBus) {
if (dataProvider == null) {
dataProvider = new SchemasPlaceDataProvider();
}
return dataProvider;
}
class SchemasPlaceDataProvider extends TreePlaceDataProvider {
@Override
protected void loadData(LoadCallback callback,
HasData<TreePlace> display) {
List<TreePlace> result = new ArrayList<TreePlace>();
result.add(new EcfVersionPlace(ecfId, ecfVersionId, ecfVersion, eventClassDtoList));
callback.onSuccess(result, display);
}
}
@Override
public TreePlace createDefaultPreviousPlace() {
return new TenantPlace(PlaceParams.getParam(USER_ID));
}
}