mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-05 03:43:52 +00:00
Merge branch 'gwt' into gwtracecolumndisplay
This commit is contained in:
commit
3616e17c13
8 files changed
+396
-36
No files matched your search
+52
-36
@@ -22,20 +22,26 @@ import com.sap.sailing.domain.swisstimingadapter.persistence.SwissTimingAdapterP
|
|||||||
public class SwissTimingAdapterPersistenceImpl implements SwissTimingAdapterPersistence {
|
public class SwissTimingAdapterPersistenceImpl implements SwissTimingAdapterPersistence {
|
||||||
|
|
||||||
private final DB database;
|
private final DB database;
|
||||||
|
|
||||||
private final SwissTimingFactory swissTimingFactory;
|
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger(SwissTimingAdapterPersistenceImpl.class.getName());
|
|
||||||
|
|
||||||
/** this race cache should only be used for checks in the storeSailMasterMessage method to ensure
|
private final SwissTimingFactory swissTimingFactory;
|
||||||
* that we have always a valid race for a message (also in case we missed a RAC message)
|
|
||||||
|
private static final Logger logger = Logger.getLogger(SwissTimingAdapterPersistenceImpl.class.getName());
|
||||||
|
|
||||||
|
private final DBCollection lastMessageCountCollection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* this race cache should only be used for checks in the storeSailMasterMessage method to ensure that we have always
|
||||||
|
* a valid race for a message (also in case we missed a RAC message)
|
||||||
*/
|
*/
|
||||||
private HashMap<String, Race> cachedRaces = new HashMap<String, Race>();
|
private HashMap<String, Race> cachedRaces = new HashMap<String, Race>();
|
||||||
|
|
||||||
|
private long lastMessageCount;
|
||||||
|
|
||||||
public SwissTimingAdapterPersistenceImpl(DB db, SwissTimingFactory swissTimingFactory) {
|
public SwissTimingAdapterPersistenceImpl(DB db, SwissTimingFactory swissTimingFactory) {
|
||||||
super();
|
super();
|
||||||
this.database = db;
|
this.database = db;
|
||||||
this.swissTimingFactory = swissTimingFactory;
|
this.swissTimingFactory = swissTimingFactory;
|
||||||
|
lastMessageCountCollection = db.getCollection(CollectionNames.LAST_MESSAGE_COUNT.name());
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,22 +54,22 @@ public class SwissTimingAdapterPersistenceImpl implements SwissTimingAdapterPers
|
|||||||
indexKeysRaceMsgs.put(FieldNames.RACE_ID.name(), 1);
|
indexKeysRaceMsgs.put(FieldNames.RACE_ID.name(), 1);
|
||||||
|
|
||||||
racesMessageCollection.ensureIndex(indexKeysRaceMsgs, IndexNames.INDEX_RACES_MESSAGES.name(), true);
|
racesMessageCollection.ensureIndex(indexKeysRaceMsgs, IndexNames.INDEX_RACES_MESSAGES.name(), true);
|
||||||
|
|
||||||
// ensure the required indexes for the collection of command messages
|
// ensure the required indexes for the collection of command messages
|
||||||
DBCollection cmdMessagesCollection = database.getCollection(CollectionNames.COMMAND_MESSAGES.name());
|
DBCollection cmdMessagesCollection = database.getCollection(CollectionNames.COMMAND_MESSAGES.name());
|
||||||
|
|
||||||
BasicDBObject indexKeysCmdMsgs = new BasicDBObject();
|
BasicDBObject indexKeysCmdMsgs = new BasicDBObject();
|
||||||
indexKeysCmdMsgs.put(FieldNames.MESSAGE_SEQUENCE_NUMBER.name(), 1);
|
indexKeysCmdMsgs.put(FieldNames.MESSAGE_SEQUENCE_NUMBER.name(), 1);
|
||||||
|
|
||||||
cmdMessagesCollection.ensureIndex(indexKeysCmdMsgs, IndexNames.INDEX_COMMAND_MESSAGES.name(), true);
|
cmdMessagesCollection.ensureIndex(indexKeysCmdMsgs, IndexNames.INDEX_COMMAND_MESSAGES.name(), true);
|
||||||
|
|
||||||
// initially fill the races cache
|
// initially fill the races cache
|
||||||
Iterable<Race> races = getRaces();
|
Iterable<Race> races = getRaces();
|
||||||
for(Race race: races) {
|
for (Race race : races) {
|
||||||
cachedRaces.put(race.getRaceID(), race);
|
cachedRaces.put(race.getRaceID(), race);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterable<SwissTimingConfiguration> getSwissTimingConfigurations() {
|
public Iterable<SwissTimingConfiguration> getSwissTimingConfigurations() {
|
||||||
List<SwissTimingConfiguration> result = new ArrayList<SwissTimingConfiguration>();
|
List<SwissTimingConfiguration> result = new ArrayList<SwissTimingConfiguration>();
|
||||||
@@ -74,8 +80,9 @@ public class SwissTimingAdapterPersistenceImpl implements SwissTimingAdapterPers
|
|||||||
result.add(stConfig);
|
result.add(stConfig);
|
||||||
}
|
}
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
// something went wrong during DB access; report, then use empty new wind track
|
// something went wrong during DB access; report, then use empty new wind track
|
||||||
logger.log(Level.SEVERE, "Error connecting to MongoDB, unable to load recorded TracTrac configurations. Check MongoDB settings.");
|
logger.log(Level.SEVERE,
|
||||||
|
"Error connecting to MongoDB, unable to load recorded TracTrac configurations. Check MongoDB settings.");
|
||||||
logger.throwing(SwissTimingAdapterPersistenceImpl.class.getName(), "getTracTracConfigurations", t);
|
logger.throwing(SwissTimingAdapterPersistenceImpl.class.getName(), "getTracTracConfigurations", t);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@@ -84,9 +91,8 @@ public class SwissTimingAdapterPersistenceImpl implements SwissTimingAdapterPers
|
|||||||
private SwissTimingConfiguration loadSwissTimingConfiguration(DBObject object) {
|
private SwissTimingConfiguration loadSwissTimingConfiguration(DBObject object) {
|
||||||
Boolean canSendRequests = (Boolean) object.get(FieldNames.ST_CONFIG_CAN_SEND_REQUESTS.name());
|
Boolean canSendRequests = (Boolean) object.get(FieldNames.ST_CONFIG_CAN_SEND_REQUESTS.name());
|
||||||
return swissTimingFactory.createSwissTimingConfiguration((String) object.get(FieldNames.ST_CONFIG_NAME.name()),
|
return swissTimingFactory.createSwissTimingConfiguration((String) object.get(FieldNames.ST_CONFIG_NAME.name()),
|
||||||
(String) object.get(FieldNames.ST_CONFIG_HOSTNAME.name()),
|
(String) object.get(FieldNames.ST_CONFIG_HOSTNAME.name()), (Integer) object
|
||||||
(Integer) object.get(FieldNames.ST_CONFIG_PORT.name()),
|
.get(FieldNames.ST_CONFIG_PORT.name()), canSendRequests == null ? false : canSendRequests);
|
||||||
canSendRequests==null?false:canSendRequests);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -110,11 +116,12 @@ public class SwissTimingAdapterPersistenceImpl implements SwissTimingAdapterPers
|
|||||||
DBCollection racesMessagesCollection = database.getCollection(CollectionNames.RACES_MESSAGES.name());
|
DBCollection racesMessagesCollection = database.getCollection(CollectionNames.RACES_MESSAGES.name());
|
||||||
BasicDBObject query = new BasicDBObject();
|
BasicDBObject query = new BasicDBObject();
|
||||||
query.append(FieldNames.RACE_ID.name(), raceID);
|
query.append(FieldNames.RACE_ID.name(), raceID);
|
||||||
DBCursor results = racesMessagesCollection.find(query).sort(new BasicDBObject().append(FieldNames.MESSAGE_SEQUENCE_NUMBER.name(), 1));
|
DBCursor results = racesMessagesCollection.find(query).sort(
|
||||||
|
new BasicDBObject().append(FieldNames.MESSAGE_SEQUENCE_NUMBER.name(), 1));
|
||||||
List<SailMasterMessage> result = new ArrayList<SailMasterMessage>();
|
List<SailMasterMessage> result = new ArrayList<SailMasterMessage>();
|
||||||
for (DBObject o : results) {
|
for (DBObject o : results) {
|
||||||
SailMasterMessage msg = swissTimingFactory.createMessage((String) o.get(FieldNames.MESSAGE_CONTENT.name()),
|
SailMasterMessage msg = swissTimingFactory.createMessage((String) o.get(FieldNames.MESSAGE_CONTENT.name()),
|
||||||
(Long) o.get(FieldNames.MESSAGE_SEQUENCE_NUMBER.name()));
|
(Long) o.get(FieldNames.MESSAGE_SEQUENCE_NUMBER.name()));
|
||||||
result.add(msg);
|
result.add(msg);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@@ -123,17 +130,17 @@ public class SwissTimingAdapterPersistenceImpl implements SwissTimingAdapterPers
|
|||||||
@Override
|
@Override
|
||||||
public List<SailMasterMessage> loadCommandMessages() {
|
public List<SailMasterMessage> loadCommandMessages() {
|
||||||
DBCollection cmdMessagesCollection = database.getCollection(CollectionNames.COMMAND_MESSAGES.name());
|
DBCollection cmdMessagesCollection = database.getCollection(CollectionNames.COMMAND_MESSAGES.name());
|
||||||
DBCursor results = cmdMessagesCollection.find().sort(new BasicDBObject().append(FieldNames.MESSAGE_SEQUENCE_NUMBER.name(), 1));
|
DBCursor results = cmdMessagesCollection.find().sort(
|
||||||
|
new BasicDBObject().append(FieldNames.MESSAGE_SEQUENCE_NUMBER.name(), 1));
|
||||||
List<SailMasterMessage> result = new ArrayList<SailMasterMessage>();
|
List<SailMasterMessage> result = new ArrayList<SailMasterMessage>();
|
||||||
for (DBObject o : results) {
|
for (DBObject o : results) {
|
||||||
SailMasterMessage msg = swissTimingFactory.createMessage((String) o.get(FieldNames.MESSAGE_CONTENT.name()),
|
SailMasterMessage msg = swissTimingFactory.createMessage((String) o.get(FieldNames.MESSAGE_CONTENT.name()),
|
||||||
(Long) o.get(FieldNames.MESSAGE_SEQUENCE_NUMBER.name()));
|
(Long) o.get(FieldNames.MESSAGE_SEQUENCE_NUMBER.name()));
|
||||||
result.add(msg);
|
result.add(msg);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Race getRace(String raceID) {
|
public Race getRace(String raceID) {
|
||||||
DBCollection races = database.getCollection(CollectionNames.RACES_MASTERDATA.name());
|
DBCollection races = database.getCollection(CollectionNames.RACES_MASTERDATA.name());
|
||||||
@@ -142,9 +149,9 @@ public class SwissTimingAdapterPersistenceImpl implements SwissTimingAdapterPers
|
|||||||
DBObject o = races.findOne(query);
|
DBObject o = races.findOne(query);
|
||||||
if (o != null) {
|
if (o != null) {
|
||||||
Long startTimeAsMillis = (Long) o.get(FieldNames.RACE_STARTTIME.name());
|
Long startTimeAsMillis = (Long) o.get(FieldNames.RACE_STARTTIME.name());
|
||||||
Race race = swissTimingFactory.createRace((String) o.get(FieldNames.RACE_ID.name()),
|
Race race = swissTimingFactory.createRace((String) o.get(FieldNames.RACE_ID.name()), (String) o
|
||||||
(String) o.get(FieldNames.RACE_DESCRIPTION.name()),
|
.get(FieldNames.RACE_DESCRIPTION.name()), startTimeAsMillis == null ? null
|
||||||
startTimeAsMillis == null ? null : new MillisecondsTimePoint(startTimeAsMillis));
|
: new MillisecondsTimePoint(startTimeAsMillis));
|
||||||
return race;
|
return race;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@@ -157,9 +164,9 @@ public class SwissTimingAdapterPersistenceImpl implements SwissTimingAdapterPers
|
|||||||
List<Race> result = new ArrayList<Race>();
|
List<Race> result = new ArrayList<Race>();
|
||||||
for (DBObject o : results) {
|
for (DBObject o : results) {
|
||||||
Long startTimeAsMillis = (Long) o.get(FieldNames.RACE_STARTTIME.name());
|
Long startTimeAsMillis = (Long) o.get(FieldNames.RACE_STARTTIME.name());
|
||||||
Race race = swissTimingFactory.createRace((String) o.get(FieldNames.RACE_ID.name()),
|
Race race = swissTimingFactory.createRace((String) o.get(FieldNames.RACE_ID.name()), (String) o
|
||||||
(String) o.get(FieldNames.RACE_DESCRIPTION.name()),
|
.get(FieldNames.RACE_DESCRIPTION.name()), startTimeAsMillis == null ? null
|
||||||
startTimeAsMillis == null ? null : new MillisecondsTimePoint(startTimeAsMillis));
|
: new MillisecondsTimePoint(startTimeAsMillis));
|
||||||
result.add(race);
|
result.add(race);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@@ -177,7 +184,7 @@ public class SwissTimingAdapterPersistenceImpl implements SwissTimingAdapterPers
|
|||||||
result.put(FieldNames.ST_CONFIG_HOSTNAME.name(), swissTimingConfiguration.getHostname());
|
result.put(FieldNames.ST_CONFIG_HOSTNAME.name(), swissTimingConfiguration.getHostname());
|
||||||
result.put(FieldNames.ST_CONFIG_PORT.name(), swissTimingConfiguration.getPort());
|
result.put(FieldNames.ST_CONFIG_PORT.name(), swissTimingConfiguration.getPort());
|
||||||
result.put(FieldNames.ST_CONFIG_CAN_SEND_REQUESTS.name(), swissTimingConfiguration.canSendRequests());
|
result.put(FieldNames.ST_CONFIG_CAN_SEND_REQUESTS.name(), swissTimingConfiguration.canSendRequests());
|
||||||
|
|
||||||
stConfigCollection.insert(result);
|
stConfigCollection.insert(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -193,6 +200,14 @@ public class SwissTimingAdapterPersistenceImpl implements SwissTimingAdapterPers
|
|||||||
if(type.isRaceSpecific()) {
|
if(type.isRaceSpecific()) {
|
||||||
objToInsert.put(FieldNames.RACE_ID.name(), message.getRaceID());
|
objToInsert.put(FieldNames.RACE_ID.name(), message.getRaceID());
|
||||||
messageCollection = database.getCollection(CollectionNames.RACES_MESSAGES.name());
|
messageCollection = database.getCollection(CollectionNames.RACES_MESSAGES.name());
|
||||||
|
if (message.getSequenceNumber() == null){
|
||||||
|
DBObject emptyQuery = new BasicDBObject();
|
||||||
|
DBObject incrementLastMessageCountQuery = new BasicDBObject().
|
||||||
|
append("$inc", new BasicDBObject().append(FieldNames.LAST_MESSAGE_COUNT.name(), 1));
|
||||||
|
DBObject newCountRecord = lastMessageCountCollection.findAndModify(emptyQuery, incrementLastMessageCountQuery);
|
||||||
|
lastMessageCount = (Long) newCountRecord.get(FieldNames.LAST_MESSAGE_COUNT.name());
|
||||||
|
objToInsert.put(FieldNames.MESSAGE_SEQUENCE_NUMBER.name(), lastMessageCount);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
messageCollection = database.getCollection(CollectionNames.COMMAND_MESSAGES.name());
|
messageCollection = database.getCollection(CollectionNames.COMMAND_MESSAGES.name());
|
||||||
}
|
}
|
||||||
@@ -225,8 +240,8 @@ public class SwissTimingAdapterPersistenceImpl implements SwissTimingAdapterPers
|
|||||||
private List<Race> parseAvailableRacesMessage(SailMasterMessage availableRacesMessage) {
|
private List<Race> parseAvailableRacesMessage(SailMasterMessage availableRacesMessage) {
|
||||||
int count = Integer.valueOf(availableRacesMessage.getSections()[1]);
|
int count = Integer.valueOf(availableRacesMessage.getSections()[1]);
|
||||||
List<Race> result = new ArrayList<Race>();
|
List<Race> result = new ArrayList<Race>();
|
||||||
for (int i=0; i<count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
String[] idAndDescription = availableRacesMessage.getSections()[2+i].split(";");
|
String[] idAndDescription = availableRacesMessage.getSections()[2 + i].split(";");
|
||||||
result.add(SwissTimingFactory.INSTANCE.createRace(idAndDescription[0], idAndDescription[1], null));
|
result.add(SwissTimingFactory.INSTANCE.createRace(idAndDescription[0], idAndDescription[1], null));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@@ -240,8 +255,9 @@ public class SwissTimingAdapterPersistenceImpl implements SwissTimingAdapterPers
|
|||||||
BasicDBObject result = new BasicDBObject();
|
BasicDBObject result = new BasicDBObject();
|
||||||
result.put(FieldNames.RACE_ID.name(), race.getRaceID());
|
result.put(FieldNames.RACE_ID.name(), race.getRaceID());
|
||||||
result.put(FieldNames.RACE_DESCRIPTION.name(), race.getDescription());
|
result.put(FieldNames.RACE_DESCRIPTION.name(), race.getDescription());
|
||||||
result.put(FieldNames.RACE_STARTTIME.name(), race.getStartTime() == null ? null : new Long(race.getStartTime().asMillis()));
|
result.put(FieldNames.RACE_STARTTIME.name(), race.getStartTime() == null ? null : new Long(race.getStartTime()
|
||||||
racesCollection.update(query, result, /* upsrt */ true, /* multi */ false);
|
.asMillis()));
|
||||||
|
racesCollection.update(query, result, /* upsrt */true, /* multi */false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -249,7 +265,7 @@ public class SwissTimingAdapterPersistenceImpl implements SwissTimingAdapterPers
|
|||||||
DBCollection racesCollection = database.getCollection(CollectionNames.RACES_MASTERDATA.name());
|
DBCollection racesCollection = database.getCollection(CollectionNames.RACES_MASTERDATA.name());
|
||||||
racesCollection.drop();
|
racesCollection.drop();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dropAllMessageData() {
|
public void dropAllMessageData() {
|
||||||
DBCollection racesMessageCollection = database.getCollection(CollectionNames.RACES_MESSAGES.name());
|
DBCollection racesMessageCollection = database.getCollection(CollectionNames.RACES_MESSAGES.name());
|
||||||
|
|||||||
+3
@@ -34,6 +34,9 @@ public class AdminConsole extends AbstractEntryPoint implements EventRefresher {
|
|||||||
eventDisplayers.add(swisstimingEventManagementPanel);
|
eventDisplayers.add(swisstimingEventManagementPanel);
|
||||||
swisstimingEventManagementPanel.setSize("90%", "90%");
|
swisstimingEventManagementPanel.setSize("90%", "90%");
|
||||||
tabPanel.add(swisstimingEventManagementPanel, stringConstants.swissTimingEvents(), false);
|
tabPanel.add(swisstimingEventManagementPanel, stringConstants.swissTimingEvents(), false);
|
||||||
|
CreateSwissTimingRacePanel createSwissTimingRacePanel = new CreateSwissTimingRacePanel(sailingService,this,stringConstants);
|
||||||
|
createSwissTimingRacePanel.setSize("90%", "90%");
|
||||||
|
tabPanel.add(createSwissTimingRacePanel,"Create SwissTiming race",false);
|
||||||
WindPanel windPanel = new WindPanel(sailingService, this, this, stringConstants);
|
WindPanel windPanel = new WindPanel(sailingService, this, this, stringConstants);
|
||||||
eventDisplayers.add(windPanel);
|
eventDisplayers.add(windPanel);
|
||||||
windPanel.setSize("90%", "90%");
|
windPanel.setSize("90%", "90%");
|
||||||
|
|||||||
+296
@@ -0,0 +1,296 @@
|
|||||||
|
package com.sap.sailing.gwt.ui.client;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.google.gwt.event.dom.client.ChangeEvent;
|
||||||
|
import com.google.gwt.event.dom.client.ChangeHandler;
|
||||||
|
import com.google.gwt.event.dom.client.ClickEvent;
|
||||||
|
import com.google.gwt.event.dom.client.ClickHandler;
|
||||||
|
import com.google.gwt.event.logical.shared.ValueChangeEvent;
|
||||||
|
import com.google.gwt.event.logical.shared.ValueChangeHandler;
|
||||||
|
import com.google.gwt.user.client.Window;
|
||||||
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
|
import com.google.gwt.user.client.ui.Button;
|
||||||
|
import com.google.gwt.user.client.ui.CaptionPanel;
|
||||||
|
import com.google.gwt.user.client.ui.FormPanel;
|
||||||
|
import com.google.gwt.user.client.ui.Grid;
|
||||||
|
import com.google.gwt.user.client.ui.HorizontalPanel;
|
||||||
|
import com.google.gwt.user.client.ui.Label;
|
||||||
|
import com.google.gwt.user.client.ui.ListBox;
|
||||||
|
import com.google.gwt.user.client.ui.MultiWordSuggestOracle;
|
||||||
|
import com.google.gwt.user.client.ui.SuggestBox;
|
||||||
|
import com.google.gwt.user.client.ui.TextBox;
|
||||||
|
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||||
|
|
||||||
|
public class CreateSwissTimingRacePanel extends FormPanel {
|
||||||
|
private TextBox txtbRaceName;
|
||||||
|
private TextBox txtbRaceDesc;
|
||||||
|
private TextBox txtbCompName;
|
||||||
|
private TextBox txtbCompSailNr;
|
||||||
|
private MultiWordSuggestOracle suggestionsCompCountr;
|
||||||
|
private SuggestBox listbCompCountr;
|
||||||
|
private ListBox listbCompetitorList;
|
||||||
|
private List<Competitor> competitors;
|
||||||
|
private int selectedIndex;
|
||||||
|
private int id = 0;
|
||||||
|
private final SailingServiceAsync service;
|
||||||
|
private ErrorReporter errorReporter;
|
||||||
|
private StringConstants stringConstants;
|
||||||
|
private long lastMessageCount;
|
||||||
|
|
||||||
|
public CreateSwissTimingRacePanel(final SailingServiceAsync sailingService, ErrorReporter errorReporter, StringConstants stringConstants){
|
||||||
|
this.service = sailingService;
|
||||||
|
this.errorReporter = errorReporter;
|
||||||
|
this.stringConstants = stringConstants;
|
||||||
|
competitors = new ArrayList<CreateSwissTimingRacePanel.Competitor>();
|
||||||
|
|
||||||
|
VerticalPanel mainPanel = new VerticalPanel();
|
||||||
|
Grid mainGrid = new Grid(3,1);
|
||||||
|
mainGrid.setWidth("100%");
|
||||||
|
mainPanel.add(mainGrid);
|
||||||
|
mainPanel.setSize("100%", "100%");
|
||||||
|
this.setWidget(mainPanel);
|
||||||
|
|
||||||
|
//Race data panel
|
||||||
|
CaptionPanel raceDataPanel = new CaptionPanel("Race");
|
||||||
|
raceDataPanel.setSize("90%", "90%");
|
||||||
|
mainGrid.setWidget(0, 0, raceDataPanel);
|
||||||
|
Grid grid = new Grid(2,2);
|
||||||
|
raceDataPanel.add(grid);
|
||||||
|
Label lblRaceName = new Label("Race name:");
|
||||||
|
grid.setWidget(0, 0, lblRaceName);
|
||||||
|
txtbRaceName = new TextBox();
|
||||||
|
grid.setWidget(0, 1, txtbRaceName);
|
||||||
|
Label lblRaceDesc = new Label("Race description:");
|
||||||
|
grid.setWidget(1, 0, lblRaceDesc);
|
||||||
|
txtbRaceDesc = new TextBox();
|
||||||
|
grid.setWidget(1, 1, txtbRaceDesc);
|
||||||
|
|
||||||
|
//Competitor panel
|
||||||
|
CaptionPanel competitorPanel = new CaptionPanel("Competitors");
|
||||||
|
competitorPanel.setSize("90%", "90%");
|
||||||
|
mainGrid.setWidget(1, 0, competitorPanel);
|
||||||
|
grid = new Grid(3,3);
|
||||||
|
competitorPanel.add(grid);
|
||||||
|
|
||||||
|
Label lblCompetitorListTitle = new Label("Competitors:");
|
||||||
|
grid.setWidget(0, 0, lblCompetitorListTitle);
|
||||||
|
listbCompetitorList = new ListBox(false);
|
||||||
|
listbCompetitorList.setVisibleItemCount(10);
|
||||||
|
listbCompetitorList.setWidth("200px");
|
||||||
|
listbCompetitorList.addChangeHandler(new ChangeHandler() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onChange(ChangeEvent event) {
|
||||||
|
competitorSelectionChanged();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
grid.setWidget(1, 0, listbCompetitorList);
|
||||||
|
|
||||||
|
VerticalPanel compData = new VerticalPanel();
|
||||||
|
grid.setWidget(1, 1, compData);
|
||||||
|
Grid subGrid = new Grid(3,2);
|
||||||
|
compData.add(subGrid);
|
||||||
|
Label lblName = new Label("Name:");
|
||||||
|
subGrid.setWidget(0, 0, lblName);
|
||||||
|
txtbCompName = new TextBox();
|
||||||
|
txtbCompName.addValueChangeHandler(new ValueChangeHandler<String>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onValueChange(ValueChangeEvent<String> event) {
|
||||||
|
competitorChanged();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
subGrid.setWidget(0, 1, txtbCompName);
|
||||||
|
Label lblSailNr = new Label("Sail number:");
|
||||||
|
subGrid.setWidget(1, 0, lblSailNr);
|
||||||
|
txtbCompSailNr = new TextBox();
|
||||||
|
txtbCompSailNr.addValueChangeHandler(new ValueChangeHandler<String>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onValueChange(ValueChangeEvent<String> event) {
|
||||||
|
competitorChanged();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
subGrid.setWidget(1, 1, txtbCompSailNr);
|
||||||
|
Label lblCountr = new Label("Country:");
|
||||||
|
subGrid.setWidget(2, 0, lblCountr);
|
||||||
|
suggestionsCompCountr = new MultiWordSuggestOracle();
|
||||||
|
service.getCountryCodes(new AsyncCallback<String[]>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(Throwable caught) {
|
||||||
|
CreateSwissTimingRacePanel.this.errorReporter.reportError("Unable to find the IOC 3-letter-codes.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSuccess(String[] result) {
|
||||||
|
for (String cc : result){
|
||||||
|
suggestionsCompCountr.add(cc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
listbCompCountr = new SuggestBox(suggestionsCompCountr);
|
||||||
|
listbCompCountr.addValueChangeHandler(new ValueChangeHandler<String>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onValueChange(ValueChangeEvent<String> event) {
|
||||||
|
competitorChanged();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
subGrid.setWidget(2, 1, listbCompCountr);
|
||||||
|
|
||||||
|
HorizontalPanel horizontalPanel = new HorizontalPanel();
|
||||||
|
grid.setWidget(2, 0, horizontalPanel);
|
||||||
|
|
||||||
|
Button bttAddCompetitor = new Button("Add");
|
||||||
|
bttAddCompetitor.setWidth("100px");
|
||||||
|
bttAddCompetitor.addClickHandler(new ClickHandler() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(ClickEvent event) {
|
||||||
|
addCompetitor();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
horizontalPanel.add(bttAddCompetitor);
|
||||||
|
|
||||||
|
Button bttDeleteCompetitor = new Button("Delete");
|
||||||
|
bttDeleteCompetitor.setWidth("100px");
|
||||||
|
bttDeleteCompetitor.addClickHandler(new ClickHandler() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(ClickEvent event) {
|
||||||
|
deleteCompetitor();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
horizontalPanel.add(bttDeleteCompetitor);
|
||||||
|
|
||||||
|
Button bttAddRace = new Button("Add race");
|
||||||
|
bttAddRace.addClickHandler(new ClickHandler() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(ClickEvent event) {
|
||||||
|
addRace();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
mainGrid.setWidget(2, 0, bttAddRace);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void competitorSelectionChanged(){
|
||||||
|
selectedIndex = listbCompetitorList.getSelectedIndex();
|
||||||
|
if (selectedIndex < 0){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String name = listbCompetitorList.getItemText(selectedIndex);
|
||||||
|
Competitor c = getCompetitorByName(name);
|
||||||
|
if (c != null){
|
||||||
|
txtbCompName.setText(c.getName());
|
||||||
|
txtbCompSailNr.setText(c.getSailNumber());
|
||||||
|
listbCompCountr.setText(c.getCountry());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addCompetitor(){
|
||||||
|
Competitor c = new Competitor(id++,"Noname","","");
|
||||||
|
listbCompetitorList.addItem(c.toString());
|
||||||
|
competitors.add(c);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void deleteCompetitor(){
|
||||||
|
if (selectedIndex < 0){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
listbCompetitorList.removeItem(selectedIndex);
|
||||||
|
competitors.remove(selectedIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void competitorChanged(){
|
||||||
|
if (selectedIndex < 0){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Competitor c = getCompetitorByName(listbCompetitorList.getItemText(selectedIndex));
|
||||||
|
if (!txtbCompName.getText().equals(c.getName())){
|
||||||
|
c.setName(txtbCompName.getText());
|
||||||
|
listbCompetitorList.setItemText(selectedIndex, c.toString());
|
||||||
|
}
|
||||||
|
c.setCountry(listbCompCountr.getText());
|
||||||
|
c.setSailNumber(txtbCompSailNr.getText());
|
||||||
|
}
|
||||||
|
|
||||||
|
private Competitor getCompetitorByName(String name){
|
||||||
|
for (Competitor c : competitors){
|
||||||
|
if (name.equals(c.toString()))
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addRace(){
|
||||||
|
String racMessage = "RAC|1|" + txtbRaceName.getText()+";" + txtbRaceDesc.getText();
|
||||||
|
|
||||||
|
String stlMessage = "STL|" + txtbRaceName.getText()+"|" + competitors.size();
|
||||||
|
for (Competitor c : competitors){
|
||||||
|
stlMessage += "|" + c.getSailNumber()+";" + c.getCountry() +";" + c.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
String ccgMessage = "CCG|" + txtbRaceName.getText() +"|3|0;LeeGate;LG1;LG2|1;Windwards;WW1|2;LeeGate;LG1;LG2";
|
||||||
|
|
||||||
|
service.sendSwissTimingDummyRace(racMessage,stlMessage,ccgMessage, new AsyncCallback<Void>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSuccess(Void result) {
|
||||||
|
Window.alert("Succesfully sended new race.");
|
||||||
|
lastMessageCount += 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(Throwable caught) {
|
||||||
|
errorReporter.reportError("Race with raceID \"" + txtbRaceName.getText() + "\" already exists.");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private class Competitor{
|
||||||
|
private String name;
|
||||||
|
private String sailNumber;
|
||||||
|
private String country;
|
||||||
|
private final int id;
|
||||||
|
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Competitor(int id, String name, String sailNumber, String country) {
|
||||||
|
super();
|
||||||
|
this.id = id;
|
||||||
|
this.name = name;
|
||||||
|
this.sailNumber = sailNumber;
|
||||||
|
this.country = country;
|
||||||
|
}
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
public String getSailNumber() {
|
||||||
|
return sailNumber;
|
||||||
|
}
|
||||||
|
public void setSailNumber(String sailNumber) {
|
||||||
|
this.sailNumber = sailNumber;
|
||||||
|
}
|
||||||
|
public String getCountry() {
|
||||||
|
return country;
|
||||||
|
}
|
||||||
|
public void setCountry(String country) {
|
||||||
|
this.country = country;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString(){
|
||||||
|
return getId() + " " + getName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+4
@@ -114,6 +114,10 @@ public interface SailingService extends RemoteService {
|
|||||||
|
|
||||||
void trackWithSwissTiming(SwissTimingRaceRecordDAO rr, String hostname, int port, boolean canSendRequests,
|
void trackWithSwissTiming(SwissTimingRaceRecordDAO rr, String hostname, int port, boolean canSendRequests,
|
||||||
boolean trackWind, boolean correctWindByDeclination) throws Exception;
|
boolean trackWind, boolean correctWindByDeclination) throws Exception;
|
||||||
|
|
||||||
|
void sendSwissTimingDummyRace(String racMessage, String stlMesssage, String ccgMessage) throws IllegalArgumentException;
|
||||||
|
|
||||||
void stressTestLeaderboardByName(String leaderboardName, int times) throws Exception;
|
void stressTestLeaderboardByName(String leaderboardName, int times) throws Exception;
|
||||||
|
|
||||||
|
String[] getCountryCodes();
|
||||||
}
|
}
|
||||||
+3
@@ -174,10 +174,13 @@ public interface SailingServiceAsync {
|
|||||||
void trackWithSwissTiming(SwissTimingRaceRecordDAO rr, String hostname, int port, boolean canSendRequests,
|
void trackWithSwissTiming(SwissTimingRaceRecordDAO rr, String hostname, int port, boolean canSendRequests,
|
||||||
boolean trackWind, boolean correctWindByDeclination, AsyncCallback<Void> asyncCallback);
|
boolean trackWind, boolean correctWindByDeclination, AsyncCallback<Void> asyncCallback);
|
||||||
|
|
||||||
|
void sendSwissTimingDummyRace(String racMessage, String stlMesssage, String ccgMessage, AsyncCallback<Void> callback);
|
||||||
/**
|
/**
|
||||||
* Requests the computation of the {@link LeaderboardDAO} for <code>leaderboardName</code> <code>times</code> times.
|
* Requests the computation of the {@link LeaderboardDAO} for <code>leaderboardName</code> <code>times</code> times.
|
||||||
* The date used for the {@link #getLeaderboardByName(String, Date, Collection, AsyncCallback)} call is iterated
|
* The date used for the {@link #getLeaderboardByName(String, Date, Collection, AsyncCallback)} call is iterated
|
||||||
* in 10ms time steps, going backwards from "now." For all races, all details are requested.
|
* in 10ms time steps, going backwards from "now." For all races, all details are requested.
|
||||||
*/
|
*/
|
||||||
void stressTestLeaderboardByName(String leaderboardName, int times, AsyncCallback<Void> callback);
|
void stressTestLeaderboardByName(String leaderboardName, int times, AsyncCallback<Void> callback);
|
||||||
|
|
||||||
|
void getCountryCodes(AsyncCallback<String[]> callback);
|
||||||
}
|
}
|
||||||
+20
@@ -117,6 +117,8 @@ public class SailingServiceImpl extends RemoteServiceServlet implements SailingS
|
|||||||
private final SwissTimingFactory swissTimingFactory;
|
private final SwissTimingFactory swissTimingFactory;
|
||||||
|
|
||||||
private final com.sap.sailing.domain.tractracadapter.persistence.DomainObjectFactory tractracDomainObjectFactory;
|
private final com.sap.sailing.domain.tractracadapter.persistence.DomainObjectFactory tractracDomainObjectFactory;
|
||||||
|
|
||||||
|
private final com.sap.sailing.util.CountryCodeFactory countryCodeFactory;
|
||||||
|
|
||||||
public SailingServiceImpl() {
|
public SailingServiceImpl() {
|
||||||
BundleContext context = Activator.getDefault();
|
BundleContext context = Activator.getDefault();
|
||||||
@@ -127,6 +129,7 @@ public class SailingServiceImpl extends RemoteServiceServlet implements SailingS
|
|||||||
tractracDomainObjectFactory = com.sap.sailing.domain.tractracadapter.persistence.DomainObjectFactory.INSTANCE;
|
tractracDomainObjectFactory = com.sap.sailing.domain.tractracadapter.persistence.DomainObjectFactory.INSTANCE;
|
||||||
tractracMongoObjectFactory = com.sap.sailing.domain.tractracadapter.persistence.MongoObjectFactory.INSTANCE;
|
tractracMongoObjectFactory = com.sap.sailing.domain.tractracadapter.persistence.MongoObjectFactory.INSTANCE;
|
||||||
swissTimingFactory = SwissTimingFactory.INSTANCE;
|
swissTimingFactory = SwissTimingFactory.INSTANCE;
|
||||||
|
countryCodeFactory = com.sap.sailing.util.CountryCodeFactory.INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ServiceTracker<RacingEventService, RacingEventService> createAndOpenRacingEventServiceTracker(
|
protected ServiceTracker<RacingEventService, RacingEventService> createAndOpenRacingEventServiceTracker(
|
||||||
@@ -1088,4 +1091,21 @@ public class SailingServiceImpl extends RemoteServiceServlet implements SailingS
|
|||||||
}.start();
|
}.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendSwissTimingDummyRace(String racMessage, String stlMesssage, String ccgMessage) {
|
||||||
|
getService().storeSwissTimingDummyRace(racMessage,stlMesssage,ccgMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String[] getCountryCodes() {
|
||||||
|
List<String> countryCodes = new ArrayList<String>();
|
||||||
|
for (CountryCode cc : countryCodeFactory.getAll()){
|
||||||
|
if (cc.getThreeLetterIOCCode() != null && !cc.getThreeLetterIOCCode().equals("")){
|
||||||
|
countryCodes.add(cc.getThreeLetterIOCCode());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Collections.sort(countryCodes);
|
||||||
|
return countryCodes.toArray(new String[0]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -184,5 +184,7 @@ public interface RacingEventService extends TrackedEventRegistry {
|
|||||||
WindStore windStore, long timeoutInMilliseconds) throws InterruptedException, UnknownHostException, IOException, ParseException;
|
WindStore windStore, long timeoutInMilliseconds) throws InterruptedException, UnknownHostException, IOException, ParseException;
|
||||||
|
|
||||||
SwissTimingFactory getSwissTimingFactory();
|
SwissTimingFactory getSwissTimingFactory();
|
||||||
|
|
||||||
|
public void storeSwissTimingDummyRace(String racMessage, String stlMesssage, String ccgMessage) throws IllegalArgumentException;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -36,6 +36,7 @@ import com.sap.sailing.domain.persistence.DomainObjectFactory;
|
|||||||
import com.sap.sailing.domain.persistence.MongoObjectFactory;
|
import com.sap.sailing.domain.persistence.MongoObjectFactory;
|
||||||
import com.sap.sailing.domain.swisstimingadapter.Race;
|
import com.sap.sailing.domain.swisstimingadapter.Race;
|
||||||
import com.sap.sailing.domain.swisstimingadapter.SailMasterConnector;
|
import com.sap.sailing.domain.swisstimingadapter.SailMasterConnector;
|
||||||
|
import com.sap.sailing.domain.swisstimingadapter.SailMasterMessage;
|
||||||
import com.sap.sailing.domain.swisstimingadapter.SwissTimingFactory;
|
import com.sap.sailing.domain.swisstimingadapter.SwissTimingFactory;
|
||||||
import com.sap.sailing.domain.swisstimingadapter.persistence.SwissTimingAdapterPersistence;
|
import com.sap.sailing.domain.swisstimingadapter.persistence.SwissTimingAdapterPersistence;
|
||||||
import com.sap.sailing.domain.tracking.DynamicTrackedEvent;
|
import com.sap.sailing.domain.tracking.DynamicTrackedEvent;
|
||||||
@@ -488,5 +489,20 @@ public class RacingEventServiceImpl implements RacingEventService {
|
|||||||
public void remove(Event event) {
|
public void remove(Event event) {
|
||||||
eventTrackingCache.remove(event);
|
eventTrackingCache.remove(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void storeSwissTimingDummyRace(String racMessage, String stlMessage, String ccgMessage){
|
||||||
|
SailMasterMessage racSMMessage = swissTimingFactory.createMessage(racMessage, null);
|
||||||
|
SailMasterMessage stlSMMessage = swissTimingFactory.createMessage(stlMessage, null);
|
||||||
|
SailMasterMessage ccgSMMessage = swissTimingFactory.createMessage(ccgMessage, null);
|
||||||
|
if (swissTimingAdapterPersistence.getRace(stlSMMessage.getRaceID()) != null) {
|
||||||
|
throw new IllegalArgumentException("Race with raceID \"" + stlSMMessage.getRaceID() + "\" already exists.");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
swissTimingAdapterPersistence.storeSailMasterMessage(racSMMessage);
|
||||||
|
swissTimingAdapterPersistence.storeSailMasterMessage(stlSMMessage);
|
||||||
|
swissTimingAdapterPersistence.storeSailMasterMessage(ccgSMMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user