mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-09-30 01:16:40 +00:00
funktioniert hoffentlich
This commit is contained in:
+2
-1
@@ -24,7 +24,8 @@ import com.sap.sailing.gwt.ui.client.shared.controls.listedit.ListEditorComposit
|
||||
|
||||
public class FleetListEditorComposite extends ListEditorComposite<FleetDTO> {
|
||||
public FleetListEditorComposite(List<FleetDTO> initialValues, StringMessages stringMessages, ImageResource removeImage) {
|
||||
super(initialValues, new ExpandedUi(stringMessages, removeImage));
|
||||
super(initialValues);
|
||||
setActiveUi(new ExpandedUi(stringMessages, removeImage));
|
||||
}
|
||||
|
||||
private static class ExpandedUi extends ExpandedListEditorUi<FleetDTO> {
|
||||
|
||||
+7
-3
@@ -17,9 +17,9 @@ import com.sap.sailing.gwt.ui.shared.SeriesDTO;
|
||||
|
||||
public class RegattaWithSeriesAndFleetsCreateDialog extends RegattaWithSeriesAndFleetsDialog {
|
||||
|
||||
private static AdminConsoleResources resources = GWT.create(AdminConsoleResources.class);
|
||||
protected static AdminConsoleResources resources = GWT.create(AdminConsoleResources.class);
|
||||
|
||||
private ListEditorComposite<SeriesDTO> seriesEditor;
|
||||
protected ListEditorComposite<SeriesDTO> seriesEditor;
|
||||
|
||||
protected static class RegattaParameterValidator implements Validator<RegattaDTO> {
|
||||
|
||||
@@ -98,9 +98,13 @@ public class RegattaWithSeriesAndFleetsCreateDialog extends RegattaWithSeriesAnd
|
||||
List<EventDTO> existingEvents, StringMessages stringConstants, DialogCallback<RegattaDTO> callback) {
|
||||
super(new RegattaDTO(), existingEvents, stringConstants.addRegatta(), stringConstants.ok(), stringConstants,
|
||||
new RegattaParameterValidator(stringConstants, existingRegattas), callback);
|
||||
this.seriesEditor = new SeriesWithFleetsListEditor(Collections.<SeriesDTO>emptyList(), stringMessages, resources.removeIcon(), /*enableFleetRemoval*/true);
|
||||
setSeriesEditor();
|
||||
}
|
||||
|
||||
protected void setSeriesEditor() {
|
||||
this.seriesEditor = new SeriesWithFleetsListEditor(Collections.<SeriesDTO>emptyList(), stringMessages, resources.removeIcon(), /*enableFleetRemoval*/true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setupAdditionalWidgetsOnPanel(final VerticalPanel panel) {
|
||||
TabPanel tabPanel = new TabPanel();
|
||||
|
||||
+6
-2
@@ -157,13 +157,17 @@ public abstract class RegattaWithSeriesAndFleetsDialog extends DataEntryDialog<R
|
||||
}
|
||||
|
||||
private void onEventSelectionChanged() {
|
||||
EventDTO selectedEvent = getSelectedEvent();
|
||||
setCourseAreaSelection();
|
||||
}
|
||||
|
||||
protected void setCourseAreaSelection() {
|
||||
EventDTO selectedEvent = getSelectedEvent();
|
||||
courseAreaListBox.clear();
|
||||
courseAreaListBox.setEnabled(false);
|
||||
if (selectedEvent != null) {
|
||||
fillCourseAreaListBox(selectedEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void fillCourseAreaListBox(EventDTO selectedEvent) {
|
||||
courseAreaListBox.addItem(stringMessages.selectCourseArea());
|
||||
|
||||
+16
-7
@@ -30,14 +30,14 @@ public class SeriesWithFleetsCreateDialog extends DataEntryDialog<SeriesDTO> {
|
||||
private StringMessages stringMessages;
|
||||
private SeriesDTO series;
|
||||
|
||||
private TextBox nameEntryField;
|
||||
protected TextBox nameEntryField;
|
||||
private CheckBox isMedalSeriesCheckbox;
|
||||
private CheckBox startsWithZeroScoreCheckbox;
|
||||
private CheckBox hasSplitFleetContiguousScoringCheckbox;
|
||||
private CheckBox firstColumnIsNonDiscardableCarryForwardCheckbox;
|
||||
private CheckBox useSeriesResultDiscardingThresholdsCheckbox;
|
||||
private DiscardThresholdBoxes discardThresholdBoxes;
|
||||
private ListEditorComposite<FleetDTO> fleetListComposite;
|
||||
protected ListEditorComposite<FleetDTO> fleetListComposite;
|
||||
|
||||
protected static class SeriesParameterValidator implements Validator<SeriesDTO> {
|
||||
private StringMessages stringMessages;
|
||||
@@ -104,9 +104,7 @@ public class SeriesWithFleetsCreateDialog extends DataEntryDialog<SeriesDTO> {
|
||||
this.stringMessages = stringMessages;
|
||||
this.series = new SeriesDTO();
|
||||
|
||||
nameEntryField = createTextBox(null);
|
||||
nameEntryField.ensureDebugId("NameTextBox");
|
||||
nameEntryField.setVisibleLength(40);
|
||||
setNameEntryField();
|
||||
|
||||
isMedalSeriesCheckbox = createCheckbox(stringMessages.medalSeries());
|
||||
isMedalSeriesCheckbox.ensureDebugId("MedalSeriesCheckbox");
|
||||
@@ -145,6 +143,12 @@ public class SeriesWithFleetsCreateDialog extends DataEntryDialog<SeriesDTO> {
|
||||
});
|
||||
}
|
||||
|
||||
protected void setNameEntryField() {
|
||||
nameEntryField = createTextBox(null);
|
||||
nameEntryField.ensureDebugId("NameTextBox");
|
||||
nameEntryField.setVisibleLength(40);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SeriesDTO getResult() {
|
||||
series.setName(nameEntryField.getText());
|
||||
@@ -152,7 +156,7 @@ public class SeriesWithFleetsCreateDialog extends DataEntryDialog<SeriesDTO> {
|
||||
series.setStartsWithZeroScore(startsWithZeroScoreCheckbox.getValue());
|
||||
series.setSplitFleetContiguousScoring(hasSplitFleetContiguousScoringCheckbox.getValue());
|
||||
series.setFirstColumnIsNonDiscardableCarryForward(firstColumnIsNonDiscardableCarryForwardCheckbox.getValue());
|
||||
series.setFleets(fleetListComposite.getValue());
|
||||
series.setFleets(fleetListComposite.getValue());
|
||||
series.setDiscardThresholds(useSeriesResultDiscardingThresholdsCheckbox.getValue() ? discardThresholdBoxes.getDiscardThresholds() : null);
|
||||
return series;
|
||||
}
|
||||
@@ -179,9 +183,14 @@ public class SeriesWithFleetsCreateDialog extends DataEntryDialog<SeriesDTO> {
|
||||
tabPanel.setWidth("100%");
|
||||
tabPanel.add(fleetListComposite, stringMessages.fleets());
|
||||
tabPanel.selectTab(0);
|
||||
panel.add(tabPanel);
|
||||
addFleetListComposite(panel, tabPanel);
|
||||
return panel;
|
||||
}
|
||||
|
||||
protected void addFleetListComposite(final VerticalPanel panel,
|
||||
TabPanel tabPanel) {
|
||||
panel.add(tabPanel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void show() {
|
||||
|
||||
+32
-25
@@ -14,43 +14,50 @@ import com.google.gwt.user.client.ui.Widget;
|
||||
import com.sap.sailing.gwt.ui.client.StringMessages;
|
||||
import com.sap.sailing.gwt.ui.client.shared.controls.listedit.ExpandedListEditorUi;
|
||||
import com.sap.sailing.gwt.ui.client.shared.controls.listedit.ListEditorComposite;
|
||||
import com.sap.sailing.gwt.ui.client.shared.controls.listedit.ListEditorUiStrategy;
|
||||
import com.sap.sailing.gwt.ui.shared.SeriesDTO;
|
||||
import com.sap.sse.gwt.client.dialog.DataEntryDialog.DialogCallback;
|
||||
|
||||
public class SeriesWithFleetsListEditor extends ListEditorComposite<SeriesDTO> {
|
||||
|
||||
public SeriesWithFleetsListEditor(List<SeriesDTO> initialValues, StringMessages stringMessages, ImageResource removeImage, boolean enableFleetRemoval) {
|
||||
super(initialValues, new ExpandedUi(stringMessages, removeImage, enableFleetRemoval));
|
||||
|
||||
public SeriesWithFleetsListEditor(List<SeriesDTO> initialValues, StringMessages stringMessages, ImageResource removeImage, boolean enableFleetRemoval) {
|
||||
super(initialValues);
|
||||
setActiveUi(createExpandedUi(stringMessages, removeImage, enableFleetRemoval));
|
||||
}
|
||||
|
||||
private static class ExpandedUi extends ExpandedListEditorUi<SeriesDTO> {
|
||||
|
||||
protected ListEditorUiStrategy<SeriesDTO> createExpandedUi(StringMessages stringMessages, ImageResource removeImage, boolean enableFleetRemoval){
|
||||
return new ExpandedUi(stringMessages, removeImage, enableFleetRemoval);
|
||||
}
|
||||
|
||||
public static class ExpandedUi extends ExpandedListEditorUi<SeriesDTO> {
|
||||
public ExpandedUi(StringMessages stringMessages, ImageResource removeImage, boolean canRemoveItems) {
|
||||
super(stringMessages, removeImage, canRemoveItems);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected Widget createAddWidget() {
|
||||
Button addSeriesButton = new Button(stringMessages.addSeries());
|
||||
addSeriesButton.ensureDebugId("AddSeriesButton");
|
||||
addSeriesButton.addClickHandler(new ClickHandler() {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
SeriesWithFleetsCreateDialog dialog = new SeriesWithFleetsCreateDialog(Collections
|
||||
.unmodifiableCollection(context.getValue()), stringMessages, new DialogCallback<SeriesDTO>() {
|
||||
@Override
|
||||
public void cancel() {
|
||||
}
|
||||
Button addSeriesButton = new Button(stringMessages.addSeries());
|
||||
addSeriesButton.ensureDebugId("AddSeriesButton");
|
||||
addSeriesButton.addClickHandler(new ClickHandler() {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
SeriesWithFleetsCreateDialog dialog = new SeriesWithFleetsCreateDialog(Collections
|
||||
.unmodifiableCollection(context.getValue()), stringMessages, new DialogCallback<SeriesDTO>() {
|
||||
@Override
|
||||
public void cancel() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ok(SeriesDTO newSeries) {
|
||||
addValue(newSeries);
|
||||
}
|
||||
});
|
||||
dialog.ensureDebugId("SeriesCreateDialog");
|
||||
dialog.show();
|
||||
}
|
||||
});
|
||||
return addSeriesButton;
|
||||
@Override
|
||||
public void ok(SeriesDTO newSeries) {
|
||||
addValue(newSeries);
|
||||
}
|
||||
});
|
||||
dialog.ensureDebugId("SeriesCreateDialog");
|
||||
dialog.show();
|
||||
}
|
||||
});
|
||||
return addSeriesButton;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+91
-47
@@ -1,16 +1,19 @@
|
||||
package com.sap.sailing.gwt.ui.adminconsole;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.github.gwtbootstrap.client.ui.base.ProgressBarBase.Style;
|
||||
import com.google.gwt.dom.client.Style.Unit;
|
||||
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.user.client.Timer;
|
||||
import com.google.gwt.user.client.Window;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.gwt.user.client.ui.Button;
|
||||
@@ -19,6 +22,7 @@ import com.google.gwt.user.client.ui.Grid;
|
||||
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
|
||||
import com.google.gwt.user.client.ui.HasVerticalAlignment;
|
||||
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.VerticalPanel;
|
||||
import com.sap.sailing.domain.common.RegattaIdentifier;
|
||||
@@ -54,6 +58,10 @@ public class StructureImportUrlsManagementPanel extends FlowPanel implements Reg
|
||||
private final Button removeButton;
|
||||
private final Button refreshButton;
|
||||
private final Button importDetailsButton;
|
||||
|
||||
private StructureImportProgressBar progressBar;
|
||||
private Label overallName;
|
||||
private int parsed;
|
||||
|
||||
public StructureImportUrlsManagementPanel(SailingServiceAsync sailingService, ErrorReporter errorReporter,
|
||||
StringMessages stringMessages, RegattaRefresher regattaRefresher, EventManagementPanel eventManagementPanel) {
|
||||
@@ -125,30 +133,6 @@ public class StructureImportUrlsManagementPanel extends FlowPanel implements Reg
|
||||
});
|
||||
VerticalPanel vp = new VerticalPanel();
|
||||
|
||||
// HorizontalPanel providerSelectionPanel = new HorizontalPanel();
|
||||
// providerSelectionPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
|
||||
// vp.add(providerSelectionPanel);
|
||||
//
|
||||
// providerSelectionPanel.add(new Label("URL Providers:"));
|
||||
// providerSelectionPanel.add(urlProviderSelectionListBox);
|
||||
//
|
||||
// sailingService.getUrlResultProviderNames(new AsyncCallback<List<String>>() {
|
||||
//
|
||||
// @Override
|
||||
// public void onSuccess(List<String> urlProviderNames) {
|
||||
// urlProviderSelectionListBox.clear();
|
||||
// urlProviderSelectionListBox.addItem("Please select a URL provider...");
|
||||
// for(String urlProviderName: urlProviderNames) {
|
||||
// urlProviderSelectionListBox.addItem(urlProviderName);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onFailure(Throwable caught) {
|
||||
// }
|
||||
// });
|
||||
|
||||
// vp.add(urlListBox);
|
||||
HorizontalPanel buttonPanel = new HorizontalPanel();
|
||||
vp.add(buttonPanel);
|
||||
buttonPanel.add(addButton);
|
||||
@@ -232,6 +216,8 @@ public class StructureImportUrlsManagementPanel extends FlowPanel implements Reg
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void createEventDetails(List<RegattaDTO> regattas) {
|
||||
List<String> regattaNamesTemp = new ArrayList<String>();
|
||||
@@ -274,28 +260,8 @@ public class StructureImportUrlsManagementPanel extends FlowPanel implements Reg
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(EventDTO newEvent) {
|
||||
eventManagementPanel.fillEvents();
|
||||
busyIndicator.setBusy(true);
|
||||
sailingService.addEventImportUrl(regattaNames, newEvent,
|
||||
new AsyncCallback<Void>() {
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
errorReporter.reportError(stringMessages
|
||||
.errorAddingResultImportUrl(caught.getMessage()));
|
||||
busyIndicator.setBusy(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(Void result) {
|
||||
regattaRefresher.fillRegattas();
|
||||
fillRegattas(new ArrayList<RegattaDTO>());
|
||||
busyIndicator.setBusy(false);
|
||||
// urlListBox.addItem(url);
|
||||
// Window.setStatus(stringMessages.successfullyUpdatedResultImportUrls());
|
||||
|
||||
}
|
||||
});
|
||||
public void onSuccess(EventDTO newEvent) {
|
||||
setDefaultRegatta(regattaNames, newEvent);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -351,5 +317,83 @@ public class StructureImportUrlsManagementPanel extends FlowPanel implements Reg
|
||||
regattaListComposite.fillRegattas(regattas);
|
||||
|
||||
}
|
||||
|
||||
private void createBarAndLabel(int amountOfRegattas){
|
||||
overallName = new Label(stringMessages.overallProgress() + ":");
|
||||
add(overallName);
|
||||
progressBar = new StructureImportProgressBar(
|
||||
amountOfRegattas+1, Style.ANIMATED);
|
||||
add(progressBar);
|
||||
}
|
||||
private void setProgressBar(final int amountOfRegattas){
|
||||
createBarAndLabel(amountOfRegattas);
|
||||
|
||||
final Timer timer = new Timer() {
|
||||
@Override
|
||||
public void run() {
|
||||
sailingService.getStructureImportOperationProgress(new AsyncCallback<Integer>(){
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
errorReporter.reportError(stringMessages
|
||||
.errorAddingResultImportUrl(caught
|
||||
.getMessage()));
|
||||
}
|
||||
@Override
|
||||
public void onSuccess(Integer result) {
|
||||
parsed = result;
|
||||
progressBar.setPercent(result);
|
||||
}
|
||||
|
||||
});
|
||||
if(parsed >= amountOfRegattas){
|
||||
regattaRefresher.fillRegattas();
|
||||
fillRegattas(new ArrayList<RegattaDTO>());
|
||||
progressBar.removeFromParent();
|
||||
overallName.removeFromParent();
|
||||
this.cancel();
|
||||
}
|
||||
}
|
||||
};
|
||||
timer.scheduleRepeating(2000);
|
||||
}
|
||||
|
||||
private void setDefaultRegatta(final List<String> regattaNames, final EventDTO newEvent){
|
||||
Collection<RegattaDTO> existingRegattas = Collections.emptyList();
|
||||
List<EventDTO> existingEvents = new ArrayList<EventDTO>();
|
||||
existingEvents.add(newEvent);
|
||||
|
||||
DefaultRegattaCreateDialog dialog = new DefaultRegattaCreateDialog(existingRegattas, existingEvents, stringMessages,
|
||||
new DialogCallback<RegattaDTO>() {
|
||||
@Override
|
||||
public void cancel() {
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
public void ok(RegattaDTO newRegatta) {
|
||||
createRegattas(regattaNames, newEvent, newRegatta);
|
||||
}
|
||||
});
|
||||
dialog.ensureDebugId("DefaultRegattaCreateDialog");
|
||||
dialog.show();
|
||||
|
||||
}
|
||||
|
||||
private void createRegattas(List<String> regattaNames, EventDTO newEvent, RegattaDTO defaultRegatta){
|
||||
eventManagementPanel.fillEvents();
|
||||
sailingService.addEventImportUrl(regattaNames, newEvent, defaultRegatta,
|
||||
new AsyncCallback<Void>() {
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
errorReporter.reportError(stringMessages
|
||||
.errorAddingResultImportUrl(caught
|
||||
.getMessage()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(Void result) {
|
||||
setProgressBar(43);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+6
-2
@@ -337,10 +337,12 @@ public interface SailingService extends RemoteService {
|
||||
void removeResultImportURLs(String resultProviderName, Set<String> toRemove) throws Exception;
|
||||
|
||||
void addResultImportUrl(String resultProviderName, String url) throws Exception;
|
||||
|
||||
void addEventImportUrl(List<String> regattaNames, EventDTO newEvent);
|
||||
|
||||
|
||||
List<RegattaDTO> getRegattas(String url);
|
||||
|
||||
void addEventImportUrl(List<String> regattaNames,EventDTO newEvent, RegattaDTO defaultRegatta);
|
||||
|
||||
|
||||
void updateLeaderboardScoreCorrectionMetadata(String leaderboardName, Date timePointOfLastCorrectionValidity,
|
||||
String comment);
|
||||
@@ -412,6 +414,8 @@ public interface SailingService extends RemoteService {
|
||||
UUID importMasterData(String host, String[] groupNames, boolean override, boolean compress, boolean exportWind);
|
||||
|
||||
DataImportProgress getImportOperationProgress(UUID id);
|
||||
|
||||
Integer getStructureImportOperationProgress();
|
||||
|
||||
Iterable<CompetitorDTO> getCompetitors();
|
||||
|
||||
|
||||
+5
-2
@@ -505,6 +505,8 @@ public interface SailingServiceAsync {
|
||||
AsyncCallback<UUID> asyncCallback);
|
||||
|
||||
void getImportOperationProgress(UUID id, AsyncCallback<DataImportProgress> asyncCallback);
|
||||
|
||||
void getStructureImportOperationProgress(AsyncCallback<Integer> asyncCallback);
|
||||
|
||||
void getLeaderboardGroupNamesFromRemoteServer(String host, AsyncCallback<List<String>> leaderboardGroupNames);
|
||||
|
||||
@@ -637,8 +639,9 @@ public interface SailingServiceAsync {
|
||||
AsyncCallback<Iterable<LeaderboardSearchResultDTO>> callback);
|
||||
|
||||
void setStartTimeReceivedForRace(RaceIdentifier raceIdentifier, Date newStartTimeReceived, AsyncCallback<RaceDTO> callback);
|
||||
|
||||
void addEventImportUrl(List<String> regattaNames, EventDTO newEvent, AsyncCallback<Void> asyncCallback);
|
||||
|
||||
void getRegattas(String url, AsyncCallback<List<RegattaDTO>> asyncCallback);
|
||||
|
||||
void addEventImportUrl(List<String> regattaNames, EventDTO newEvent,RegattaDTO defaultRegatta, AsyncCallback<Void> asyncCallback);
|
||||
|
||||
}
|
||||
|
||||
+1
@@ -9,6 +9,7 @@ public interface StringMessages extends Messages {
|
||||
String helloWorld();
|
||||
String kielWeel2011();
|
||||
String stgAccount();
|
||||
String setDefaultSeries();
|
||||
String tracTracEvents();
|
||||
String swissTimingEvents();
|
||||
String trackedBefore();
|
||||
|
||||
+1
@@ -1,6 +1,7 @@
|
||||
helloWorld=Hello World
|
||||
kielWeel2011=Kiel Week 2011
|
||||
stgAccount=STG Account
|
||||
setDefaultSeries=Set Default Series
|
||||
tracTracEvents=TracTrac Events
|
||||
swissTimingEvents=SwissTiming Events
|
||||
trackedBefore=History of tracked events
|
||||
|
||||
+7
-4
@@ -35,18 +35,21 @@ import com.google.gwt.user.client.ui.HasValue;
|
||||
public class ListEditorComposite<ValueType> extends Composite implements HasValue<List<ValueType>>,
|
||||
HasValueChangeHandlers<List<ValueType>> {
|
||||
|
||||
private final ListEditorUiStrategy<ValueType> activeUi;
|
||||
private ListEditorUiStrategy<ValueType> activeUi = null;
|
||||
|
||||
private List<ValueType> values;
|
||||
|
||||
public ListEditorComposite(List<ValueType> initialValues, ListEditorUiStrategy<ValueType> activeUi) {
|
||||
public ListEditorComposite(List<ValueType> initialValues) {
|
||||
this.values = new ArrayList<ValueType>(initialValues);
|
||||
this.activeUi = activeUi;
|
||||
}
|
||||
|
||||
public void setActiveUi(ListEditorUiStrategy<ValueType> activeUi) {
|
||||
this.activeUi = activeUi;
|
||||
this.activeUi.setContext(this);
|
||||
|
||||
initWidget(activeUi.initWidget());
|
||||
activeUi.refresh();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ValueType> getValue() {
|
||||
|
||||
+6
-3
@@ -18,17 +18,20 @@ import com.sap.sailing.gwt.ui.client.StringMessages;
|
||||
public class StringListEditorComposite extends ListEditorComposite<String> {
|
||||
public StringListEditorComposite(List<String> initialValues, StringMessages stringMessages,
|
||||
String popupDialogTitle, ImageResource removeImage, List<String> suggestValues) {
|
||||
super(initialValues, new CollapsedUi(stringMessages, popupDialogTitle,
|
||||
super(initialValues);
|
||||
setActiveUi(new CollapsedUi(stringMessages, popupDialogTitle,
|
||||
new ExpandedUi(stringMessages, removeImage, suggestValues)));
|
||||
}
|
||||
|
||||
public StringListEditorComposite(List<String> initialValues, StringMessages stringMessages,
|
||||
ImageResource removeImage, List<String> suggestValues) {
|
||||
super(initialValues, new ExpandedUi(stringMessages, removeImage, suggestValues));
|
||||
super(initialValues);
|
||||
setActiveUi(new ExpandedUi(stringMessages, removeImage, suggestValues));
|
||||
}
|
||||
|
||||
public StringListEditorComposite(List<String> initialValues, ListEditorUiStrategy<String> activeUi) {
|
||||
super(initialValues, activeUi);
|
||||
super(initialValues);
|
||||
setActiveUi(activeUi);
|
||||
}
|
||||
|
||||
public static class CollapsedUi extends CollapsedListEditorUi<String> {
|
||||
|
||||
+97
-57
@@ -387,6 +387,7 @@ import com.sap.sailing.server.replication.ReplicationService;
|
||||
import com.sap.sailing.server.replication.impl.ReplicaDescriptor;
|
||||
import com.sap.sailing.util.BuildVersion;
|
||||
import com.sap.sailing.xrr.schema.RegattaResults;
|
||||
import com.sap.sailing.xrr.structureimport.SeriesParameters;
|
||||
import com.sap.sailing.xrr.structureimport.StructureImportUrl;
|
||||
import com.sap.sse.common.Util;
|
||||
import com.sap.sse.common.Util.Pair;
|
||||
@@ -449,7 +450,6 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
|
||||
|
||||
private int leaderboardDifferenceCacheByIdPairHits;
|
||||
private int leaderboardDifferenceCacheByIdPairMisses;
|
||||
private StructureImportUrl structureImport;
|
||||
/**
|
||||
* Caches some results of the hard to compute difference between two {@link LeaderboardDTO}s. The objects contained
|
||||
* as values have been obtained by {@link IncrementalLeaderboardDTO#strip(LeaderboardDTO)}. The cache size is
|
||||
@@ -460,6 +460,8 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
|
||||
private final SwissTimingReplayService swissTimingReplayService;
|
||||
|
||||
private final QuickRanksLiveCache quickRanksLiveCache;
|
||||
|
||||
private StructureImportUrl structureImport = null;
|
||||
|
||||
public SailingServiceImpl() {
|
||||
BundleContext context = Activator.getDefault();
|
||||
@@ -3720,35 +3722,90 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
|
||||
return convertToRegattaDTO(regatta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addEventImportUrl(List<String> regattaNames, EventDTO newEvent) {
|
||||
|
||||
Regatta regatta = null;
|
||||
structureImport.updateRegattasToSelected(regattaNames);
|
||||
|
||||
// create Regattas
|
||||
ArrayList<CourseAreaDTO> courseAreas = (ArrayList<CourseAreaDTO>) newEvent.venue.getCourseAreas();
|
||||
ArrayList<AddSpecificRegatta> regattas = structureImport.getRegattas(courseAreas.get(0).id);
|
||||
List<List<List<String>>> series = structureImport.getRaceNames();
|
||||
|
||||
String eventName = structureImport.getEventName();
|
||||
ArrayList<String> leaderboardNames = new ArrayList<String>();
|
||||
|
||||
for (int i = 0; i < regattas.size(); i++) {
|
||||
regatta = getService().apply(regattas.get(i));
|
||||
|
||||
// create Races
|
||||
int j = 0;
|
||||
for (Series s : regatta.getSeries()) {
|
||||
addRaceColumnsToSeries(regatta.getRegattaIdentifier(), s.getName(), series.get(i).get(j));
|
||||
j++;
|
||||
}
|
||||
|
||||
if (getLeaderboard(regatta.getName()) == null) {
|
||||
leaderboardNames.add(regatta.getName());
|
||||
createRegattaLeaderboard(regatta.getRegattaIdentifier(), eventName, new int[0]);
|
||||
}
|
||||
|
||||
private SeriesParameters getDefaultSeries(RegattaDTO defaultRegatta){
|
||||
SeriesParameters defaultSeries = new SeriesParameters(false, false, false, null);
|
||||
if(defaultRegatta.series.size()>0){
|
||||
SeriesDTO series = defaultRegatta.series.get(0);
|
||||
defaultSeries.setFirstColumnIsNonDiscardableCarryForward(series.isFirstColumnIsNonDiscardableCarryForward());
|
||||
defaultSeries.setHasSplitFleetContiguousScoring(series.hasSplitFleetContiguousScoring());
|
||||
defaultSeries.setStartswithZeroScore(series.isStartsWithZeroScore());
|
||||
defaultSeries.setDiscardingThresholds(series.getDiscardThresholds());
|
||||
}
|
||||
return defaultSeries;
|
||||
}
|
||||
|
||||
public List<RegattaDTO> getRegattas(String url) {
|
||||
structureImport = new StructureImportUrl(url, new SetRacenumberFromSeries());
|
||||
RegattaDTO regattaDTO = null;
|
||||
ArrayList<Regattas> regattas = structureImport.getRegattas();
|
||||
List<RegattaDTO> regattasDTO = new ArrayList<RegattaDTO>();
|
||||
for (int i = 0; i < regattas.size(); i++) {
|
||||
regattaDTO = new RegattaDTO(regattas.get(i).getName(), null);
|
||||
regattasDTO.add(regattaDTO);
|
||||
}
|
||||
return regattasDTO;
|
||||
}
|
||||
|
||||
private ArrayList<String> createRegattasWithRaces(
|
||||
ArrayList<AddSpecificRegatta> regattas, String eventName) {
|
||||
|
||||
ArrayList<String> leaderboardNames = new ArrayList<String>();
|
||||
List<List<List<String>>> series = structureImport.getRaceNames();
|
||||
|
||||
for (int i = 0; i < regattas.size(); i++) {
|
||||
Regatta regatta = getService().apply(regattas.get(i));
|
||||
|
||||
// create Races
|
||||
int j = 0;
|
||||
for (Series s : regatta.getSeries()) {
|
||||
addRaceColumnsToSeries(regatta.getRegattaIdentifier(), s.getName(), series.get(i).get(j));
|
||||
j++;
|
||||
}
|
||||
|
||||
if (getLeaderboard(regatta.getName()) == null) {
|
||||
leaderboardNames.add(regatta.getName());
|
||||
createRegattaLeaderboard(regatta.getRegattaIdentifier(), eventName, new int[0]);
|
||||
}
|
||||
}
|
||||
return leaderboardNames;
|
||||
}
|
||||
@Override
|
||||
public void addEventImportUrl(final List<String> regattaNames, final EventDTO newEvent, final RegattaDTO defaultRegatta) {
|
||||
|
||||
Runnable structureImportTask = new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
structureImport.updateRegattasToSelected(regattaNames);
|
||||
|
||||
// set default settings for series
|
||||
SeriesParameters defaultSeries = getDefaultSeries(defaultRegatta);
|
||||
|
||||
// get Regattas
|
||||
ArrayList<AddSpecificRegatta> regattas = structureImport.getRegattas(defaultRegatta.scoringScheme, false, defaultRegatta.defaultCourseAreaUuid,
|
||||
defaultRegatta.useStartTimeInference, getBaseDomainFactory(), defaultSeries.isFirstColumnIsNonDiscardableCarryForward(),
|
||||
defaultSeries.isHasSplitFleetContiguousScoring(),
|
||||
defaultSeries.isStartswithZeroScore(), defaultSeries.getDiscardingThresholds());
|
||||
|
||||
String eventName = structureImport.getEventName();
|
||||
ArrayList<String> leaderboardNames = createRegattasWithRaces(
|
||||
regattas, eventName);
|
||||
//create Leaderboard Group
|
||||
createAndAddLeaderboardGroup(newEvent, eventName, leaderboardNames);
|
||||
structureImport.setCompetitors();
|
||||
structureImport.resetSeriesForRegattas();
|
||||
structureImport.setFinished(true);
|
||||
|
||||
}
|
||||
};
|
||||
executor.execute(structureImportTask);
|
||||
}
|
||||
|
||||
|
||||
private void createAndAddLeaderboardGroup(final EventDTO newEvent,
|
||||
String eventName, ArrayList<String> leaderboardNames){
|
||||
LeaderboardGroupDTO leaderboardGroupDTO = null;
|
||||
// create Leaderboard Group
|
||||
try { /*mit if abfangen*/
|
||||
@@ -3761,34 +3818,6 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
|
||||
updateLeaderboardGroup(eventName, eventName, "", eventName, leaderboardNames, null, null);
|
||||
leaderboardGroupDTO = getLeaderboardGroupByName(eventName, false);
|
||||
}
|
||||
List<UUID> uuids = new ArrayList<UUID>();
|
||||
uuids.add(leaderboardGroupDTO.getId());
|
||||
// add created Leaderboard Group to event
|
||||
try {
|
||||
updateEvent(newEvent.id, newEvent.getName(), newEvent.getDescription(), newEvent.startDate,
|
||||
newEvent.endDate, newEvent.venue, newEvent.isPublic, uuids, newEvent.getOfficialWebsiteURL(),
|
||||
newEvent.getLogoImageURL(), newEvent.getImageURLs(), newEvent.getVideoURLs(),
|
||||
newEvent.getSponsorImageURLs());
|
||||
} catch (MalformedURLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
structureImport.setCompetitors(getBaseDomainFactory());
|
||||
structureImport.resetSeriesForRegattas();
|
||||
|
||||
}
|
||||
|
||||
public List<RegattaDTO> getRegattas(String url) {
|
||||
structureImport = new StructureImportUrl(url, new SetRacenumberFromSeries());
|
||||
RegattaDTO regattaDTO = null;
|
||||
ArrayList<Regattas> regattas = structureImport.getRegattas();
|
||||
List<RegattaDTO> regattasDTO = new ArrayList<RegattaDTO>();
|
||||
for (int i = 0; i < regattas.size(); i++) {
|
||||
regattaDTO = new RegattaDTO(regattas.get(i).getName(), null);
|
||||
regattasDTO.add(regattaDTO);
|
||||
}
|
||||
return regattasDTO;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -4386,6 +4415,17 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
|
||||
public DataImportProgress getImportOperationProgress(UUID id) {
|
||||
return getService().getDataImportLock().getProgress(id);
|
||||
}
|
||||
|
||||
public Integer getStructureImportOperationProgress(){
|
||||
int parsedDocuments = 0;
|
||||
if(structureImport != null){
|
||||
parsedDocuments = structureImport.getProgress();
|
||||
if(structureImport.isFinished()){
|
||||
parsedDocuments++;
|
||||
}
|
||||
}
|
||||
return parsedDocuments;
|
||||
}
|
||||
|
||||
private String createLeaderboardQuery(String[] groupNames, boolean compress, boolean exportWind)
|
||||
throws UnsupportedEncodingException {
|
||||
|
||||
@@ -4,19 +4,19 @@ Bundle-Name: Structureimport
|
||||
Bundle-SymbolicName: com.sap.sailing.xrr.structureimportCopy
|
||||
Bundle-Version: 1.6.0.qualifier
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
|
||||
Export-Package: buildstructure;uses:="com.sap.sailing.xrr.resultimport.schema",
|
||||
Export-Package: .,
|
||||
buildstructure;uses:="com.sap.sailing.xrr.resultimport.schema",
|
||||
com.sap.sailing.xrr.structureimport,
|
||||
eventimport
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Require-Bundle: com.google.gwt.osgi;bundle-version="2.6.0",
|
||||
com.sap.sailing.domain.common;bundle-version="1.0.0",
|
||||
com.sap.sailing.domain,
|
||||
com.sap.sse.common;bundle-version="1.0.0",
|
||||
com.sap.sailing.resultimport;bundle-version="1.0.0",
|
||||
com.sap.sailing.xrr.schema;bundle-version="1.0.0",
|
||||
com.sap.sailing.xrr.resultimport;bundle-version="1.0.0"
|
||||
Import-Package: com.sap.sailing.domain.base.impl,
|
||||
com.sap.sailing.server.operationaltransformation,
|
||||
com.sap.sailing.xrr.resultimport;bundle-version="1.0.0",
|
||||
com.sap.sse.common;bundle-version="1.0.0",
|
||||
com.sap.sailing.resultimport;bundle-version="1.0.0"
|
||||
Import-Package: com.sap.sailing.server.operationaltransformation,
|
||||
com.sap.sailing.xrr.schema,
|
||||
org.json.simple,
|
||||
org.json.simple.parser,
|
||||
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
package com.sap.sailing.xrr.structureimport;
|
||||
|
||||
public class SeriesParameters {
|
||||
private boolean firstColumnIsNonDiscardableCarryForward = false;
|
||||
private boolean hasSplitFleetContiguousScoring = false;
|
||||
private boolean startswithZeroScore = false;
|
||||
private int[] discardingThresholds = null;
|
||||
|
||||
public SeriesParameters(boolean firstColumnIsNonDiscardableCarryForward,
|
||||
boolean hasSplitFleetContiguousScoring,
|
||||
boolean startswithZeroScore, int[] discardingThresholds) {
|
||||
this.firstColumnIsNonDiscardableCarryForward = firstColumnIsNonDiscardableCarryForward;
|
||||
this.hasSplitFleetContiguousScoring = hasSplitFleetContiguousScoring;
|
||||
this.startswithZeroScore = startswithZeroScore;
|
||||
this.discardingThresholds = discardingThresholds;
|
||||
}
|
||||
public boolean isFirstColumnIsNonDiscardableCarryForward() {
|
||||
return firstColumnIsNonDiscardableCarryForward;
|
||||
}
|
||||
public void setFirstColumnIsNonDiscardableCarryForward(
|
||||
boolean firstColumnIsNonDiscardableCarryForward) {
|
||||
this.firstColumnIsNonDiscardableCarryForward = firstColumnIsNonDiscardableCarryForward;
|
||||
}
|
||||
public boolean isHasSplitFleetContiguousScoring() {
|
||||
return hasSplitFleetContiguousScoring;
|
||||
}
|
||||
public void setHasSplitFleetContiguousScoring(
|
||||
boolean hasSplitFleetContiguousScoring) {
|
||||
this.hasSplitFleetContiguousScoring = hasSplitFleetContiguousScoring;
|
||||
}
|
||||
public boolean isStartswithZeroScore() {
|
||||
return startswithZeroScore;
|
||||
}
|
||||
public void setStartswithZeroScore(boolean startswithZeroScore) {
|
||||
this.startswithZeroScore = startswithZeroScore;
|
||||
}
|
||||
public int[] getDiscardingThresholds() {
|
||||
return discardingThresholds;
|
||||
}
|
||||
public void setDiscardingThresholds(int[] discardingThresholds) {
|
||||
this.discardingThresholds = discardingThresholds;
|
||||
}
|
||||
}
|
||||
+144
-121
@@ -31,6 +31,7 @@ import com.sap.sailing.domain.base.impl.PersonImpl;
|
||||
import com.sap.sailing.domain.base.impl.RegattaImpl;
|
||||
import com.sap.sailing.domain.base.impl.TeamImpl;
|
||||
import com.sap.sailing.domain.common.Color;
|
||||
import com.sap.sailing.domain.common.ScoringSchemeType;
|
||||
import com.sap.sailing.domain.common.dto.FleetDTO;
|
||||
import com.sap.sailing.domain.common.dto.RegattaCreationParametersDTO;
|
||||
import com.sap.sailing.domain.common.dto.SeriesCreationParametersDTO;
|
||||
@@ -58,24 +59,25 @@ public class StructureImportUrl {
|
||||
private LinkedHashMap<String, Boat> boatForPerson;
|
||||
private DomainFactory baseDomainFactory;
|
||||
private SetRacenumberStrategy setRacenumberStrategy;
|
||||
private int parsedDocuments = 0;
|
||||
private boolean finished = false;
|
||||
|
||||
public StructureImportUrl(String url, SetRacenumberStrategy setRacenumber) {
|
||||
|
||||
this.setRacenumberStrategy = setRacenumber;
|
||||
this.setRacenumberStrategy = setRacenumber;
|
||||
regattas = new EventImport().getRegattas(url);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public ArrayList<Regattas> getRegattas(){
|
||||
|
||||
public ArrayList<Regattas> getRegattas() {
|
||||
return regattas;
|
||||
}
|
||||
|
||||
public void updateRegattasToSelected(List<String> regattaNames){
|
||||
|
||||
public void updateRegattasToSelected(List<String> regattaNames) {
|
||||
ArrayList<Regattas> regattasTemp = new ArrayList<Regattas>();
|
||||
for(Regattas regatta: regattas){
|
||||
for(String s: regattaNames){
|
||||
if(regatta.getName().equals(s)){
|
||||
for (Regattas regatta : regattas) {
|
||||
for (String s : regattaNames) {
|
||||
if (regatta.getName().equals(s)) {
|
||||
regattasTemp.add(regatta);
|
||||
}
|
||||
}
|
||||
@@ -83,34 +85,44 @@ public class StructureImportUrl {
|
||||
regattas = regattasTemp;
|
||||
}
|
||||
|
||||
public ArrayList<AddSpecificRegatta> getRegattas(Serializable courseAreaID) {
|
||||
ArrayList<AddSpecificRegatta> regattas = new ArrayList<AddSpecificRegatta>();
|
||||
Event event = null;
|
||||
results.clear();
|
||||
|
||||
for (int i = 0; i < this.regattas.size(); i++) {
|
||||
public void parseEvent() {
|
||||
|
||||
for (int i = 0; i < regattas.size(); i++) {
|
||||
try {
|
||||
parseRegattaXML(this.regattas.get(i).getXrrEntriesUrl());
|
||||
parseRegattaXML(regattas.get(i).getXrrEntriesUrl());
|
||||
} catch (FileNotFoundException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (JAXBException e) {
|
||||
// TODO Auto-generated catch block
|
||||
// TODO Auto-generated catch blocks
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
parsedDocuments++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public ArrayList<AddSpecificRegatta> getRegattas(ScoringSchemeType scoringScheme, boolean isPersistent,
|
||||
UUID courseArea, boolean useStartTimeInference, DomainFactory baseDomainFactory,
|
||||
boolean firstColumnIsNonDiscardableCarryForward, boolean hasSplitFleetContiguousScoring,
|
||||
boolean startswithZeroScore, int[] discardingThresholds) {
|
||||
|
||||
this.baseDomainFactory = baseDomainFactory;
|
||||
ArrayList<AddSpecificRegatta> regattas = new ArrayList<AddSpecificRegatta>();
|
||||
Event event = null;
|
||||
results.clear();
|
||||
parseEvent();
|
||||
|
||||
for (int i = 0; i < results.size(); i++) {
|
||||
|
||||
ArrayList<Race> races = new ArrayList<Race>();
|
||||
|
||||
event = (Event) results.get(i).getPersonOrBoatOrTeam()
|
||||
.get(results.get(i).getPersonOrBoatOrTeam().size() - 1);
|
||||
|
||||
|
||||
List<Object> raceOrDevisionOrRegattaSeries = event.getRaceOrDivisionOrRegattaSeriesResult();
|
||||
for (int j = 1; j < raceOrDevisionOrRegattaSeries.size(); j++) {
|
||||
races.add((Race) raceOrDevisionOrRegattaSeries.get(j));
|
||||
@@ -118,26 +130,28 @@ public class StructureImportUrl {
|
||||
|
||||
BuildStructure structure = new BuildStructure(races);
|
||||
|
||||
LinkedHashMap<String, SeriesCreationParametersDTO> seriesCreationParams = setSeriesCreationParametersDTO(structure);
|
||||
LinkedHashMap<String, SeriesCreationParametersDTO> seriesCreationParams = setSeriesCreationParametersDTO(
|
||||
structure, firstColumnIsNonDiscardableCarryForward, hasSplitFleetContiguousScoring,
|
||||
startswithZeroScore, discardingThresholds);
|
||||
|
||||
regattas.add(new AddSpecificRegatta(RegattaImpl.getDefaultName(event.getTitle(), ((Division) event
|
||||
.getRaceOrDivisionOrRegattaSeriesResult().get(0)).getTitle()), ((Division) event
|
||||
.getRaceOrDivisionOrRegattaSeriesResult().get(0)).getTitle(), event.getEventID(),
|
||||
new RegattaCreationParametersDTO(seriesCreationParams), /* persistent */
|
||||
true, new LowPoint(), courseAreaID, /* useStartTimeInference */true));
|
||||
new RegattaCreationParametersDTO(seriesCreationParams), isPersistent, this.baseDomainFactory
|
||||
.createScoringScheme(scoringScheme), courseArea, useStartTimeInference));
|
||||
|
||||
}
|
||||
eventName = event.getTitle();
|
||||
return regattas;
|
||||
}
|
||||
|
||||
public String getEventName(){
|
||||
|
||||
public String getEventName() {
|
||||
return eventName;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private LinkedHashMap<String, SeriesCreationParametersDTO> setSeriesCreationParametersDTO(BuildStructure structure) {
|
||||
private LinkedHashMap<String, SeriesCreationParametersDTO> setSeriesCreationParametersDTO(BuildStructure structure,
|
||||
boolean firstColumnIsNonDiscardableCarryForward, boolean hasSplitFleetContiguousScoring,
|
||||
boolean startswithZeroScore, int[] discardingThresholds) {
|
||||
LinkedHashMap<String, SeriesCreationParametersDTO> seriesCreationParams = new LinkedHashMap<String, SeriesCreationParametersDTO>();
|
||||
|
||||
RegattaStructure regattaStructure = structure.getRegattaStructure();
|
||||
@@ -164,18 +178,18 @@ public class StructureImportUrl {
|
||||
}
|
||||
List<String> raceNames = new ArrayList<String>();
|
||||
raceNames.clear();
|
||||
|
||||
//set Racenumbers for each series
|
||||
|
||||
// set Racenumbers for each series
|
||||
Race[] races = fleets.get(raceType.getMaxIndex()).getRaces();
|
||||
for (int j = 0; j < races.length; j++) {
|
||||
Race race = races[j];
|
||||
Race race = races[j];
|
||||
setRacenumberStrategy.setRacenumber(race, raceType, i, raceNames);
|
||||
}
|
||||
series.add(raceNames);
|
||||
|
||||
seriesCreationParams.put(raceType.getRaceType(), new SeriesCreationParametersDTO(fleetsDTO,
|
||||
/* medal */raceTypes.get(i).isMedal(), /* startsWithZero */false, /* firstColumnIsNonDiscardableCarryForward */false,
|
||||
/* discardingThresholds */null, /* hasSplitFleetContiguousScoring */false));
|
||||
/* medal */raceTypes.get(i).isMedal(), startswithZeroScore, firstColumnIsNonDiscardableCarryForward,
|
||||
discardingThresholds, hasSplitFleetContiguousScoring));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -218,98 +232,96 @@ public class StructureImportUrl {
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
public void setCompetitors(DomainFactory baseDomainFactory){
|
||||
|
||||
this.baseDomainFactory = baseDomainFactory;
|
||||
|
||||
for(int i=0;i<results.size();i++){
|
||||
BoatClass boatClass = null;
|
||||
|
||||
if(regattas.get(i).getBoatClass() != null){
|
||||
boatClass = baseDomainFactory.getOrCreateBoatClass(regattas.get(i).getBoatClass());
|
||||
}else{
|
||||
boatClass = baseDomainFactory.getOrCreateBoatClass("default");
|
||||
}
|
||||
|
||||
|
||||
public void setCompetitors() {
|
||||
|
||||
for (int i = 0; i < results.size(); i++) {
|
||||
BoatClass boatClass = null;
|
||||
|
||||
if (regattas.get(i).getBoatClass() != null) {
|
||||
boatClass = baseDomainFactory.getOrCreateBoatClass(regattas.get(i).getBoatClass());
|
||||
} else {
|
||||
boatClass = baseDomainFactory.getOrCreateBoatClass("default");
|
||||
}
|
||||
|
||||
ArrayList<Object> personOrBoatOrTeam = (ArrayList<Object>) results.get(i).getPersonOrBoatOrTeam();
|
||||
|
||||
setBoatsAndTeamsForPerson(personOrBoatOrTeam);
|
||||
|
||||
|
||||
setBoatsAndTeamsForPerson(personOrBoatOrTeam);
|
||||
|
||||
for (int j = 0; j < personOrBoatOrTeam.size(); j++) {
|
||||
if(personOrBoatOrTeam.get(j) instanceof Person){
|
||||
Person person = (Person) personOrBoatOrTeam.get(j);
|
||||
String idAsString = person.getPersonID();
|
||||
|
||||
String name = person.getGivenName() + " " + person.getFamilyName();
|
||||
Color color = null;
|
||||
Nationality nationality = (person.getNOC() == null) ? null : getNationality(
|
||||
person.getNOC().toString());
|
||||
|
||||
BoatAndTeam boatAndTeam = getBoatAndTeam(idAsString, name, nationality, boatClass);
|
||||
|
||||
baseDomainFactory.convertToCompetitorDTO(
|
||||
baseDomainFactory.getOrCreateCompetitor(UUID.fromString(idAsString), name,
|
||||
color, boatAndTeam.getTeam(), boatAndTeam.getBoat()));
|
||||
}else{
|
||||
break;
|
||||
if (personOrBoatOrTeam.get(j) instanceof Person) {
|
||||
Person person = (Person) personOrBoatOrTeam.get(j);
|
||||
String idAsString = person.getPersonID();
|
||||
|
||||
String name = person.getGivenName() + " " + person.getFamilyName();
|
||||
Color color = null;
|
||||
Nationality nationality = (person.getNOC() == null) ? null : getNationality(person.getNOC()
|
||||
.toString());
|
||||
|
||||
BoatAndTeam boatAndTeam = getBoatAndTeam(idAsString, name, nationality, boatClass);
|
||||
|
||||
baseDomainFactory.convertToCompetitorDTO(baseDomainFactory.getOrCreateCompetitor(
|
||||
UUID.fromString(idAsString), name, color, boatAndTeam.getTeam(), boatAndTeam.getBoat()));
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private Nationality getNationality(String country){
|
||||
return baseDomainFactory.getOrCreateNationality(country);
|
||||
}
|
||||
|
||||
private void setBoatsAndTeamsForPerson(ArrayList<Object >personOrBoatOrTeam){
|
||||
|
||||
boatForPerson = new LinkedHashMap<String, Boat>();
|
||||
LinkedHashMap<String, Team> teamForBoat = new LinkedHashMap<String, Team>();
|
||||
|
||||
for (int i=0; i < personOrBoatOrTeam.size(); i++) {
|
||||
if(personOrBoatOrTeam.get(i) instanceof Team){
|
||||
teamForBoat.put(((Team)personOrBoatOrTeam.get(i)).getBoatID(), (Team)personOrBoatOrTeam.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < personOrBoatOrTeam.size(); i++) {
|
||||
if(personOrBoatOrTeam.get(i) instanceof Boat){
|
||||
Team team = teamForBoat.get(((Boat)personOrBoatOrTeam.get(i)).getBoatID());
|
||||
|
||||
ArrayList<Crew> crew = (ArrayList<Crew>) team.getCrew();
|
||||
for (int j = 0; j < crew.size(); j++) {
|
||||
boatForPerson.put(crew.get(j).getPersonID(), (Boat)personOrBoatOrTeam.get(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private BoatAndTeam getBoatAndTeam(String idAsString, String name, Nationality nationality, BoatClass boatClass){
|
||||
|
||||
DynamicBoat boat = createBoat(name, boatForPerson.get(idAsString), boatClass);
|
||||
if(nationality == null){
|
||||
String country = "";
|
||||
if(boat.getSailID().length()>=3){
|
||||
for (int i = 0; i < 3; i++) {
|
||||
country += boat.getSailID().charAt(i);
|
||||
}
|
||||
|
||||
nationality = getNationality(country);
|
||||
}
|
||||
}
|
||||
DynamicTeam team = createTeam(name, nationality);
|
||||
return new BoatAndTeam(boat, team);
|
||||
}
|
||||
|
||||
private DynamicBoat createBoat(String name, Boat boat, BoatClass boatClass){
|
||||
|
||||
DynamicBoat boat1 = new BoatImpl(name + " boat", boatClass, boat.getSailNumber());
|
||||
return boat1;
|
||||
|
||||
private Nationality getNationality(String country) {
|
||||
return baseDomainFactory.getOrCreateNationality(country);
|
||||
}
|
||||
private DynamicTeam createTeam(String name, Nationality nationality){
|
||||
|
||||
private void setBoatsAndTeamsForPerson(ArrayList<Object> personOrBoatOrTeam) {
|
||||
|
||||
boatForPerson = new LinkedHashMap<String, Boat>();
|
||||
LinkedHashMap<String, Team> teamForBoat = new LinkedHashMap<String, Team>();
|
||||
|
||||
for (int i = 0; i < personOrBoatOrTeam.size(); i++) {
|
||||
if (personOrBoatOrTeam.get(i) instanceof Team) {
|
||||
teamForBoat.put(((Team) personOrBoatOrTeam.get(i)).getBoatID(), (Team) personOrBoatOrTeam.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < personOrBoatOrTeam.size(); i++) {
|
||||
if (personOrBoatOrTeam.get(i) instanceof Boat) {
|
||||
Team team = teamForBoat.get(((Boat) personOrBoatOrTeam.get(i)).getBoatID());
|
||||
|
||||
ArrayList<Crew> crew = (ArrayList<Crew>) team.getCrew();
|
||||
for (int j = 0; j < crew.size(); j++) {
|
||||
boatForPerson.put(crew.get(j).getPersonID(), (Boat) personOrBoatOrTeam.get(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private BoatAndTeam getBoatAndTeam(String idAsString, String name, Nationality nationality, BoatClass boatClass) {
|
||||
|
||||
DynamicBoat boat = createBoat(name, boatForPerson.get(idAsString), boatClass);
|
||||
if (nationality == null) {
|
||||
String country = "";
|
||||
if (boat.getSailID().length() >= 3) {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
country += boat.getSailID().charAt(i);
|
||||
}
|
||||
|
||||
nationality = getNationality(country);
|
||||
}
|
||||
}
|
||||
DynamicTeam team = createTeam(name, nationality);
|
||||
return new BoatAndTeam(boat, team);
|
||||
}
|
||||
|
||||
private DynamicBoat createBoat(String name, Boat boat, BoatClass boatClass) {
|
||||
|
||||
DynamicBoat boat1 = new BoatImpl(name + " boat", boatClass, boat.getSailNumber());
|
||||
return boat1;
|
||||
}
|
||||
|
||||
private DynamicTeam createTeam(String name, Nationality nationality) {
|
||||
DynamicPerson sailor = new PersonImpl(name, nationality, null, null);
|
||||
DynamicTeam team = new TeamImpl(name + " team", Collections.singleton(sailor), null);
|
||||
return team;
|
||||
@@ -321,7 +333,7 @@ public class StructureImportUrl {
|
||||
|
||||
private void parseRegattaXML(String url) throws FileNotFoundException, JAXBException, IOException {
|
||||
results.add(ParserFactory.INSTANCE.createParser(getInputStream(url), "").parse());
|
||||
|
||||
|
||||
}
|
||||
|
||||
private InputStream getInputStream(String url) throws FileNotFoundException, IOException {
|
||||
@@ -330,10 +342,21 @@ public class StructureImportUrl {
|
||||
|
||||
return connection.getInputStream();
|
||||
}
|
||||
|
||||
public void resetSeriesForRegattas(){
|
||||
|
||||
public void resetSeriesForRegattas() {
|
||||
seriesForRegattas.clear();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public int getProgress() {
|
||||
return parsedDocuments;
|
||||
}
|
||||
|
||||
public boolean isFinished() {
|
||||
return finished;
|
||||
}
|
||||
|
||||
public void setFinished(boolean finished) {
|
||||
this.finished = finished;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user