Merge remote-tracking branch 'server/master'

This commit is contained in:
Axel Uhl committed 2015-10-14 11:34:03 +02:00
commit 4e8416fffe
17 files changed
+234 -105

No files matched your search

@@ -64,6 +64,7 @@
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;runtimeClasspathEntry internalArchive=&quot;/com.sap.sse.security.ui/src/main/java&quot; path=&quot;3&quot; type=&quot;2&quot;/&gt;&#13;&#10;"/>
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;runtimeClasspathEntry internalArchive=&quot;/com.sap.sse.gwt.adminconsole/src&quot; path=&quot;3&quot; type=&quot;2&quot;/&gt;&#13;&#10;"/>
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;runtimeClasspathEntry internalArchive=&quot;/com.sap.sse.security.common/src&quot; path=&quot;3&quot; type=&quot;2&quot;/&gt;&#13;&#10;"/>
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;runtimeClasspathEntry internalArchive=&quot;/com.sap.sailing.polars.datamining.shared/src&quot; path=&quot;3&quot; type=&quot;2&quot;/&gt;&#13;&#10;"/>
</listAttribute>
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="com.google.gwt.eclipse.core.moduleClasspathProvider"/>
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="false"/>
@@ -1244,7 +1244,7 @@ public interface StringMessages extends com.sap.sse.gwt.client.StringMessages, c
String distanceTraveledIncludingGateStartTooltip();
String raceDistanceTraveledIncludingGateStartTooltip();
String results();
String group();
String groupName();
String valueAscending();
String valueDescending();
String sortBy();
@@ -1410,4 +1410,8 @@ public interface StringMessages extends com.sap.sse.gwt.client.StringMessages, c
String flightsCount(@PluralCount(DefaultRule_1_0n.class) int count);
String viewQueryDefinition();
String queryDefinitionViewer();
String groupAverageAscending();
String groupAverageDescending();
String groupMedianAscending();
String groupMedianDescending();
}
@@ -1212,7 +1212,7 @@ distanceIncludingGateStartInMeters=Distance (w/ Gate Start)
distanceTraveledIncludingGateStartTooltip=The distance traveled from the leg start to the end\nor to the current time point, if the leg isn''t finished.\nIf the leg includes a gate start, the distance from the pin end to the starting position is included\nto make competitors comparable even when started at different times.
raceDistanceTraveledIncludingGateStartTooltip=The distance traveled from the race start to the end\nor to the current time point, if the race isn''t finished. For a gate start, the distance from the pin end to the starting position is included\nto make competitors comparable even when started at different times.
results=Results
group=Group
groupName=Group Name
valueAscending=Value (Ascending)
valueDescending=Value (Descending)
sortBy=Sort by
@@ -1381,4 +1381,8 @@ smartphoneTracking=Smartphone Tracking
flightsCount={0,number} flights
flightsCount[one]={0,number} flight
viewQueryDefinition=View Query Definition
queryDefinitionViewer=Query Definition Viewer
queryDefinitionViewer=Query Definition Viewer
groupAverageAscending=Group Average (Ascending)
groupAverageDescending=Group Average (Descending)
groupMedianAscending=Group Median (Ascending)
groupMedianDescending=Group Median (Descending)
@@ -1201,7 +1201,7 @@ distanceIncludingGateStartInMeters=Distanz (m. Torstart)
distanceTraveledIncludingGateStartTooltip=Die zurückgelegt Strecke vom Start des Schenkels bis zum Ende\noder bis zum aktuellen Zeitpunkt, falls der Schenkel noch nicht beendet ist.\nEnthält der Schenkel einen Torstart, so wird die Distanz vom Pin End bis zur Startposition des Teilnehmers hinzugezählt,\num so vergleichbare Distanzen auch für Teilneher zu erhalten, die zu verschiedenen Zeiten gestartet sind.
raceDistanceTraveledIncludingGateStartTooltip=Die zurückgelegte Strecke vom Start des Rennens, bis zum Ende\noder bis zum aktuellen Zeitpunkt, falls das Rennen noch nicht beendet ist. Bei einem Torstart wird die Distanz vom Pin End bis zur Startposition des Teilnehmers hinzugezählt,\num so vergleichbare Distanzen auch für Teilneher zu erhalten, die zu verschiedenen Zeiten gestartet sind.
results=Ergebnisse
group=Gruppe
groupName=Gruppename
valueAscending=Wert (Aufsteigend)
valueDescending=Wert (Absteigend)
sortBy=Sortiert nach
@@ -1370,4 +1370,8 @@ smartphoneTracking=Smartphone Tracking
flightsCount={0,number} Läufe
flightsCount[one]={0,number} Lauf
viewQueryDefinition=Query Definition anzeigen
queryDefinitionViewer=Query Definition Anzeiger
queryDefinitionViewer=Query Definition Anzeiger
groupAverageAscending=Gruppe Durchschnitt (Aufsteigend)
groupAverageDescending=Gruppe Durchschnitt (Absteigend)
groupMedianAscending=Gruppe Median (Aufsteigend)
groupMedianDescending=Gruppe Median (Absteigend)
@@ -1145,7 +1145,7 @@ distanceIncludingGateStartInMeters=Distance (w/ Gate Start)
distanceTraveledIncludingGateStartTooltip=The distance traveled from the leg start to the end\nor to the current time point, if the leg isn''t finished.\nIf the leg includes a gate start, the distance from the pin end to the starting position is included\nto make competitors comparable even when started at different times.
raceDistanceTraveledIncludingGateStartTooltip=The distance traveled from the race start to the end\nor to the current time point, if the race isn''t finished. For a gate start, the distance from the pin end to the starting position is included\nto make competitors comparable even when started at different times.
results=Results
group=Group
groupName=Group Name
valueAscending=Value (Ascending)
valueDescending=Value (Descending)
sortBy=Sort by
@@ -1310,4 +1310,8 @@ actionAnalyze=Analyze
viewQueryDefinition=View Query Definition
queryDefinitionViewer=Query Definition Viewer
flightsCount={0,number} flights
flightsCount[one]={0,number} flight
flightsCount[one]={0,number} flight
groupAverageAscending=Group Average (Ascending)
groupAverageDescending=Group Average (Descending)
groupMedianAscending=Group Median (Ascending)
groupMedianDescending=Group Median (Descending)
@@ -16,6 +16,7 @@ import com.sap.sailing.gwt.ui.client.StringMessages;
import com.sap.sailing.gwt.ui.client.shared.controls.AbstractObjectRenderer;
import com.sap.sailing.gwt.ui.datamining.ResultsPresenterWithControls;
import com.sap.sse.common.settings.Settings;
import com.sap.sse.datamining.shared.GroupKey;
import com.sap.sse.datamining.shared.impl.dto.QueryResultDTO;
public abstract class AbstractResultsPresenter<SettingsType extends Settings> implements ResultsPresenterWithControls<SettingsType> {
@@ -34,6 +35,7 @@ public abstract class AbstractResultsPresenter<SettingsType extends Settings> im
private final HTML labeledBusyIndicator;
private QueryResultDTO<?> currentResult;
private boolean isCurrentResultSimple;
public AbstractResultsPresenter(StringMessages stringMessages) {
this.stringMessages = stringMessages;
@@ -99,11 +101,12 @@ public abstract class AbstractResultsPresenter<SettingsType extends Settings> im
}
this.currentResult = result;
updateIsCurrentResultSimple();
internalShowResults(getCurrentResult());
} else {
this.currentResult = null;
updateIsCurrentResultSimple();
showError(getStringMessages().noDataFound() + ".");
}
}
@@ -121,6 +124,7 @@ public abstract class AbstractResultsPresenter<SettingsType extends Settings> im
}
currentResult = null;
updateIsCurrentResultSimple();
presentationPanel.setWidget(errorLabel);
}
@@ -142,6 +146,25 @@ public abstract class AbstractResultsPresenter<SettingsType extends Settings> im
}
currentResult = null;
updateIsCurrentResultSimple();
}
private void updateIsCurrentResultSimple() {
boolean isSimple = false;
if (currentResult != null) {
isSimple = true;
for (GroupKey groupKey : getCurrentResult().getResults().keySet()) {
if (groupKey.hasSubKey()) {
isSimple = false;
break;
}
}
}
isCurrentResultSimple = isSimple;
}
protected boolean isCurrentResultSimple() {
return isCurrentResultSimple;
}
protected StringMessages getStringMessages() {
@@ -48,7 +48,7 @@ public class ResultsChart extends AbstractResultsPresenterWithDataProviders<Sett
}
@Override
public String toString() {
return getStringMessages().group();
return getStringMessages().groupName();
};
};
private final Comparator<GroupKey> ascendingByValueKeyComparator = new Comparator<GroupKey>() {
@@ -73,6 +73,46 @@ public class ResultsChart extends AbstractResultsPresenterWithDataProviders<Sett
return getStringMessages().valueDescending();
};
};
private final Comparator<GroupKey> ascendingByGroupAverageComparator = new Comparator<GroupKey>() {
@Override
public int compare(GroupKey key1, GroupKey key2) {
GroupKey mainKey1 = key1.getMainKey();
GroupKey mainKey2 = key2.getMainKey();
return Double.compare(averagePerMainKey.get(mainKey1), averagePerMainKey.get(mainKey2));
}
public String toString() {
return getStringMessages().groupAverageAscending();
};
};
private final Comparator<GroupKey> descendingByGroupAverageComparator = new Comparator<GroupKey>() {
@Override
public int compare(GroupKey key1, GroupKey key2) {
return -1 * ascendingByGroupAverageComparator.compare(key1, key2);
}
public String toString() {
return getStringMessages().groupAverageDescending();
};
};
private final Comparator<GroupKey> ascendingByGroupMedianComparator = new Comparator<GroupKey>() {
@Override
public int compare(GroupKey key1, GroupKey key2) {
GroupKey mainKey1 = key1.getMainKey();
GroupKey mainKey2 = key2.getMainKey();
return Double.compare(medianPerMainKey.get(mainKey1), medianPerMainKey.get(mainKey2));
}
public String toString() {
return getStringMessages().groupMedianAscending();
};
};
private final Comparator<GroupKey> descendingByGroupMedianComparator = new Comparator<GroupKey>() {
@Override
public int compare(GroupKey key1, GroupKey key2) {
return -1 * ascendingByGroupMedianComparator.compare(key1, key2);
}
public String toString() {
return getStringMessages().groupMedianDescending();
};
};
private final HorizontalPanel sortByPanel;
private final ValueListBox<Comparator<GroupKey>> keyComparatorListBox;
@@ -80,11 +120,14 @@ public class ResultsChart extends AbstractResultsPresenterWithDataProviders<Sett
private final SimpleLayoutPanel chartPanel;
private final Chart chart;
private Map<GroupKey, Series> seriesMappedByGroupKey;
private final Map<GroupKey, Series> seriesMappedByGroupKey;
private final GroupKey simpleResultSeriesKey;
private Map<GroupKey, Integer> mainKeyToXValueMap;
private final Map<GroupKey, Integer> mainKeyToXValueMap;
private Map<GroupKey, Number> currentResultValues;
private final Map<GroupKey, Double> averagePerMainKey;
private final Map<GroupKey, Double> medianPerMainKey;
public ResultsChart(StringMessages stringMessages) {
super(stringMessages);
@@ -137,6 +180,9 @@ public class ResultsChart extends AbstractResultsPresenterWithDataProviders<Sett
seriesMappedByGroupKey = new HashMap<GroupKey, Series>();
simpleResultSeriesKey = new GenericGroupKey<String>(stringMessages.results());
mainKeyToXValueMap = new HashMap<>();
averagePerMainKey = new HashMap<>();
medianPerMainKey = new HashMap<>();
}
@Override
@@ -159,10 +205,16 @@ public class ResultsChart extends AbstractResultsPresenterWithDataProviders<Sett
Comparator<GroupKey> valueToBeSelected = standardKeyComparator;
Collection<Comparator<GroupKey>> acceptableValues = new ArrayList<>();
acceptableValues.add(valueToBeSelected);
if (getCurrentResult() != null && isCurrentResultSimple()) {
valueToBeSelected = getKeyComparator() != null ? getKeyComparator() : valueToBeSelected;
acceptableValues.add(ascendingByValueKeyComparator);
acceptableValues.add(descendingByValueKeyComparator);
if (getCurrentResult() != null) {
if (isCurrentResultSimple()) {
acceptableValues.add(ascendingByValueKeyComparator);
acceptableValues.add(descendingByValueKeyComparator);
} else {
acceptableValues.add(ascendingByGroupAverageComparator);
acceptableValues.add(descendingByGroupAverageComparator);
acceptableValues.add(ascendingByGroupMedianComparator);
acceptableValues.add(descendingByGroupMedianComparator);
}
visible = true;
}
keyComparatorListBox.setValue(valueToBeSelected);
@@ -170,18 +222,9 @@ public class ResultsChart extends AbstractResultsPresenterWithDataProviders<Sett
sortByPanel.setVisible(visible);
}
private boolean isCurrentResultSimple() {
for (GroupKey groupKey : getCurrentResult().getResults().keySet()) {
if (groupKey.hasSubKey()) {
return false;
}
}
return true;
}
private void resetChartSeries() {
chart.removeAllSeries(false);
seriesMappedByGroupKey = new HashMap<GroupKey, Series>();
seriesMappedByGroupKey.clear();
}
private void updateChartLabels() {
@@ -198,21 +241,66 @@ public class ResultsChart extends AbstractResultsPresenterWithDataProviders<Sett
buildMainKeyMapAndSetXAxisCategories();
createAndAddSeriesToChart();
Map<GroupKey, List<Number>> valuesPerMainKey = new HashMap<>();
for (Entry<GroupKey, ? extends Number> resultEntry : currentResultValues.entrySet()) {
GroupKey mainKey = resultEntry.getKey().getMainKey();
Point point = new Point(mainKeyToXValueMap.get(mainKey), resultEntry.getValue());
Number value = resultEntry.getValue();
if (!isCurrentResultSimple()) {
if (!valuesPerMainKey.containsKey(mainKey)) {
valuesPerMainKey.put(mainKey, new ArrayList<Number>());
}
valuesPerMainKey.get(mainKey).add(value);
}
Point point = new Point(mainKeyToXValueMap.get(mainKey), value);
point.setName(mainKey.asString());
seriesMappedByGroupKey.get(groupKeyToSeriesKey(resultEntry.getKey()))
.addPoint(point, false, false, false);
}
averagePerMainKey.clear();
medianPerMainKey.clear();
if (!isCurrentResultSimple()) {
for (GroupKey mainKey : valuesPerMainKey.keySet()) {
List<Number> values = valuesPerMainKey.get(mainKey);
averagePerMainKey.put(mainKey, getAverageFromValues(values));
medianPerMainKey.put(mainKey, getMedianFromValues(values));
}
}
chart.redraw();
}
private Double getAverageFromValues(Collection<Number> values) {
double sum = 0;
for (Number value : values) {
sum += value.doubleValue();
}
return sum / values.size();
}
private Double getMedianFromValues(List<Number> values) {
Collections.sort(values, new Comparator<Number>() {
@Override
public int compare(Number n1, Number n2) {
return Double.compare(n1.doubleValue(), n2.doubleValue());
}
});
if (values.size() % 2 == 0) {
int index1 = (values.size() / 2) - 1;
int index2 = index1 + 1;
return (values.get(index1).doubleValue() + values.get(index2).doubleValue()) / 2;
} else {
int index = ((values.size() + 1) / 2) - 1;
return values.get(index).doubleValue();
}
}
private void buildMainKeyMapAndSetXAxisCategories() {
List<GroupKey> sortedMainKeys = getSortedMainKeys();
String[] categories = new String[sortedMainKeys.size()];
mainKeyToXValueMap = new HashMap<>();
mainKeyToXValueMap.clear();
for (int i = 0; i < sortedMainKeys.size(); i++) {
GroupKey mainKey = sortedMainKeys.get(i);
categories[i] = mainKey.asString();
@@ -49,7 +49,7 @@ public class DataRetrieverLevelDTO implements Serializable, Comparable<DataRetri
@Override
public String toString() {
return retrieverTypeName + "[retrievedDataType: " + retrievedDataType + "]";
return getRetrieverTypeName() + "[retrievedDataType: " + getRetrievedDataType() + "]";
}
@Override
@@ -69,20 +69,7 @@ public class FunctionDTO implements Serializable, Comparable<FunctionDTO> {
}
public String toString() {
return (isDimension() ? "Dimension " : "Function ") + sourceTypeName + "." + functionName + "(" + parametersAsString() + ") : " + returnTypeName;
}
private String parametersAsString() {
StringBuilder parameterBuilder = new StringBuilder();
boolean first = true;
for (String parameterTypeName : parameterTypeNames) {
if (!first) {
parameterBuilder.append(", ");
}
parameterBuilder.append(parameterTypeName);
first = false;
}
return parameterBuilder.toString();
return (isDimension() ? "Dimension " : "Function ") + getSourceTypeName() + "." + getFunctionName() + " : " + getReturnTypeName();
}
@Override
@@ -49,7 +49,7 @@ public class TestCompoundFunction {
//This is a workaround, because the assertion, that to types are equal checks for an instance of the given class instead.
assertThat("The actual declaring class did'nt match the expected one.",
compoundFunction.getDeclaringType().equals(MarkedContainer.class), is(true));
assertThat(compoundFunction.getSimpleName(), is("getContainerElement -> getName"));
assertThat(compoundFunction.getSimpleName(), is("getContainerElement().getName()"));
assertThat(compoundFunction.getLocalizedName(Locale.ENGLISH, TestsUtil.getTestStringMessages()), is("Name"));
assertThat(compoundFunction.getResultDecimals(), is(0));
}
@@ -40,16 +40,16 @@ public class TestFunctionDTOConstruction {
public void testDimensionDTOConstruction() {
Function<?> dimension = FunctionTestsUtil.getFunctionFactory().createMethodWrappingFunction(dimensionMethod);
FunctionDTO expectedDimensionDTO = createExpectedDimensionDTO();
FunctionDTO expectedDimensionDTO = createExpectedDimensionDTO(dimension);
assertThat(FunctionTestsUtil.getDTOFactory().createFunctionDTO(dimension), is(expectedDimensionDTO));
assertThat(FunctionTestsUtil.getDTOFactory().createFunctionDTO(dimension, stringMessages, Locale.ENGLISH), is(expectedDimensionDTO));
assertThat(FunctionTestsUtil.getDTOFactory().createFunctionDTO(dimension, stringMessages, Locale.GERMAN), is(expectedDimensionDTO));
}
public FunctionDTO createExpectedDimensionDTO() {
String functionName = dimensionMethod.getName();
String sourceTypeName = dimensionMethod.getDeclaringClass().getSimpleName();
String returnTypeName = dimensionMethod.getReturnType().getSimpleName();
public FunctionDTO createExpectedDimensionDTO(Function<?> dimension) {
String functionName = dimension.getSimpleName();
String sourceTypeName = dimension.getDeclaringType().getName();
String returnTypeName = dimension.getReturnType().getName();
List<String> parameterTypeNames = new ArrayList<>();
String displayName = functionName;
@@ -63,15 +63,15 @@ public class TestFunctionDTOConstruction {
public void testNullarySideEffectFreeValueDTOConstruction() {
Function<?> sideEffectFreeValue = FunctionTestsUtil.getFunctionFactory().createMethodWrappingFunction(sideEffectFreeValueMethod);
FunctionDTO expectedDTO = createExpectedNullarySideEffectFreeValueDTO();
FunctionDTO expectedDTO = createExpectedNullarySideEffectFreeValueDTO(sideEffectFreeValue);
assertThat(FunctionTestsUtil.getDTOFactory().createFunctionDTO(sideEffectFreeValue, stringMessages, Locale.ENGLISH), is(expectedDTO));
assertThat(FunctionTestsUtil.getDTOFactory().createFunctionDTO(sideEffectFreeValue, stringMessages, Locale.GERMAN), is(expectedDTO));
}
private FunctionDTO createExpectedNullarySideEffectFreeValueDTO() {
String functionName = sideEffectFreeValueMethod.getName();
String sourceTypeName = sideEffectFreeValueMethod.getDeclaringClass().getSimpleName();
String returnTypeName = sideEffectFreeValueMethod.getReturnType().getSimpleName();
private FunctionDTO createExpectedNullarySideEffectFreeValueDTO(Function<?> sideEffectFreeValue) {
String functionName = sideEffectFreeValue.getSimpleName();
String sourceTypeName = sideEffectFreeValue.getDeclaringType().getName();
String returnTypeName = sideEffectFreeValue.getReturnType().getName();
List<String> parameterTypeNames = new ArrayList<>();
String displayName = functionName;
@@ -85,15 +85,15 @@ public class TestFunctionDTOConstruction {
public void testExternalLibraryFunctionDTOConstruction() {
Function<?> externalLibraryFunction = FunctionTestsUtil.getFunctionFactory().createMethodWrappingFunction(externalLibraryMethod);
FunctionDTO expectedDTO = createExpectedExternalLibraryFunctionDTO();
FunctionDTO expectedDTO = createExpectedExternalLibraryFunctionDTO(externalLibraryFunction);
assertThat(FunctionTestsUtil.getDTOFactory().createFunctionDTO(externalLibraryFunction, stringMessages, Locale.ENGLISH), is(expectedDTO));
assertThat(FunctionTestsUtil.getDTOFactory().createFunctionDTO(externalLibraryFunction, stringMessages, Locale.GERMAN), is(expectedDTO));
}
private FunctionDTO createExpectedExternalLibraryFunctionDTO() {
String functionName = externalLibraryMethod.getName();
String sourceTypeName = externalLibraryMethod.getDeclaringClass().getSimpleName();
String returnTypeName = externalLibraryMethod.getReturnType().getSimpleName();
private FunctionDTO createExpectedExternalLibraryFunctionDTO(Function<?> externalLibraryFunction) {
String functionName = externalLibraryFunction.getSimpleName();
String sourceTypeName = externalLibraryFunction.getDeclaringType().getName();
String returnTypeName = externalLibraryFunction.getReturnType().getName();
List<String> parameterTypeNames = new ArrayList<>();
String displayName = functionName;
@@ -107,17 +107,17 @@ public class TestFunctionDTOConstruction {
public void testFunctionDTOConstructionForMethodWithParameters() {
Function<?> increment = FunctionTestsUtil.getFunctionFactory().createMethodWrappingFunction(incrementMethod);
FunctionDTO expectedDTO = createFunctionDTOWithParameters();
FunctionDTO expectedDTO = createFunctionDTOWithParameters(increment);
assertThat(FunctionTestsUtil.getDTOFactory().createFunctionDTO(increment, stringMessages, Locale.ENGLISH), is(expectedDTO));
assertThat(FunctionTestsUtil.getDTOFactory().createFunctionDTO(increment, stringMessages, Locale.GERMAN), is(expectedDTO));
}
private FunctionDTO createFunctionDTOWithParameters() {
String functionName = incrementMethod.getName();
String sourceTypeName = incrementMethod.getDeclaringClass().getSimpleName();
String returnTypeName = incrementMethod.getReturnType().getSimpleName();
private FunctionDTO createFunctionDTOWithParameters(Function<?> increment) {
String functionName = increment.getSimpleName();
String sourceTypeName = increment.getDeclaringType().getName();
String returnTypeName = increment.getReturnType().getName();
List<String> parameterTypeNames = new ArrayList<>();
parameterTypeNames.add(int.class.getSimpleName());
parameterTypeNames.add(int.class.getName());
String displayName = functionName;
boolean isDimension = false;
@@ -64,7 +64,7 @@ public class TestMethodWrappingFunction {
assertThat(sideEffectFreeValue.getLocalizedName(Locale.GERMAN, stringMessages), is(expectedGermanName));
Function<?> externalLibraryFunction = FunctionTestsUtil.getFunctionFactory().createMethodWrappingFunction(externalLibraryMethod);
String expectedName = "foo";
String expectedName = "foo()";
assertThat(externalLibraryFunction.getLocalizedName(Locale.ENGLISH, stringMessages), is(expectedName));
assertThat(externalLibraryFunction.getLocalizedName(Locale.GERMAN, stringMessages), is(expectedName));
}
@@ -39,8 +39,8 @@ public class DataMiningDTOFactory {
private FunctionDTO createFunctionDTO(Function<?> function, String displayName) {
String functionName = function.getSimpleName();
String sourceTypeName = function.getDeclaringType().getSimpleName();
String returnTypeName = function.getReturnType().getSimpleName();
String sourceTypeName = function.getDeclaringType().getName();
String returnTypeName = function.getReturnType().getName();
List<String> parameterTypeNames = getParameterTypeNames(function);
return new FunctionDTO(function.isDimension(), functionName, sourceTypeName, returnTypeName, parameterTypeNames, displayName, function.getOrdinal());
}
@@ -48,7 +48,7 @@ public class DataMiningDTOFactory {
private List<String> getParameterTypeNames(Function<?> function) {
List<String> parameterTypeNames = new ArrayList<>();
for (Class<?> parameterType : function.getParameters()) {
parameterTypeNames.add(parameterType.getSimpleName());
parameterTypeNames.add(parameterType.getName());
}
return parameterTypeNames;
}
@@ -72,8 +72,8 @@ public class DataMiningDTOFactory {
private AggregationProcessorDefinitionDTO createAggregationProcessorDefinitionDTO(AggregationProcessorDefinition<?, ?> aggregatorDefinition, String displayName) {
return new AggregationProcessorDefinitionDTO(aggregatorDefinition.getAggregationNameMessageKey(),
aggregatorDefinition.getExtractedType().getSimpleName(),
aggregatorDefinition.getAggregatedType().getSimpleName(),
aggregatorDefinition.getExtractedType().getName(),
aggregatorDefinition.getAggregatedType().getName(),
displayName);
}
@@ -85,12 +85,12 @@ public class DataMiningDTOFactory {
}
return new DataRetrieverChainDefinitionDTO(dataRetrieverChainDefinition.getID(),
dataRetrieverChainDefinition.getLocalizedName(locale, stringMessages), dataRetrieverChainDefinition
.getDataSourceType().getSimpleName(), retrieverLevels);
.getDataSourceType().getName(), retrieverLevels);
}
public DataRetrieverLevelDTO createDataRetrieverLevelDTO(DataRetrieverLevel<?, ?> retrieverLevel,
ResourceBundleStringMessages stringMessages, Locale locale) {
String typeName = retrieverLevel.getRetrievedDataType().getSimpleName();
String typeName = retrieverLevel.getRetrievedDataType().getName();
String displayName = retrieverLevel.getRetrievedDataTypeMessageKey() != null
&& !retrieverLevel.getRetrievedDataTypeMessageKey().isEmpty() ? stringMessages
.get(locale, retrieverLevel.getRetrievedDataTypeMessageKey()) : typeName;
@@ -36,7 +36,7 @@ import com.sap.sse.datamining.functions.Function;
import com.sap.sse.datamining.impl.components.DataRetrieverLevel;
import com.sap.sse.datamining.impl.components.management.AbstractMemoryMonitorAction;
import com.sap.sse.datamining.impl.components.management.QueryManagerMemoryMonitor;
import com.sap.sse.datamining.impl.components.management.RuntimeMemorInfoProvider;
import com.sap.sse.datamining.impl.components.management.RuntimeMemoryInfoProvider;
import com.sap.sse.datamining.impl.components.management.StrategyPerQueryTypeManager;
import com.sap.sse.datamining.shared.DataMiningSession;
import com.sap.sse.datamining.shared.dto.StatisticQueryDefinitionDTO;
@@ -74,7 +74,7 @@ public class DataMiningServerImpl implements ModifiableDataMiningServer {
componentsChangedTimepoint = new Date();
this.queryFactory = new QueryFactory();
dataMiningQueryManager = new StrategyPerQueryTypeManager();
memoryMonitor = new QueryManagerMemoryMonitor(new RuntimeMemorInfoProvider(Runtime.getRuntime()), dataMiningQueryManager,
memoryMonitor = new QueryManagerMemoryMonitor(new RuntimeMemoryInfoProvider(Runtime.getRuntime()), dataMiningQueryManager,
createMemoryMonitorActions(), MEMORY_CHECK_PERIOD, MEMORY_CHECK_PERIOD_UNIT);
this.functionRegistry = functionRegistry;
this.dataSourceProviderRegistry = dataSourceProviderRegistry;
@@ -2,11 +2,11 @@ package com.sap.sse.datamining.impl.components.management;
import com.sap.sse.datamining.components.management.MemoryInfoProvider;
public class RuntimeMemorInfoProvider implements MemoryInfoProvider {
public class RuntimeMemoryInfoProvider implements MemoryInfoProvider {
private Runtime runtime;
public RuntimeMemorInfoProvider(Runtime runtime) {
public RuntimeMemoryInfoProvider(Runtime runtime) {
this.runtime = runtime;
}
@@ -19,7 +19,7 @@ import com.sap.sse.i18n.ResourceBundleStringMessages;
*/
public class ConcatenatingCompoundFunction<ReturnType> extends AbstractFunction<ReturnType> {
private static final String SIMPLE_NAME_CHAIN_CONNECTOR = " -> ";
private static final String SIMPLE_NAME_CHAIN_CONNECTOR = ".";
private static final String LOCALIZED_NAME_CHAIN_CONNECTOR = " ";
private final List<Function<?>> functions;
@@ -17,15 +17,15 @@ public class MethodWrappingFunction<ReturnType> extends AbstractFunction<ReturnT
private final Method method;
private Class<ReturnType> returnType;
private AdditionalMethodWrappingFunctionData additionalData;
/**
* Throws an {@link IllegalArgumentException}, if the return type of the method and the given <code>returnType</code>
* aren't equal.
* Throws an {@link IllegalArgumentException}, if the return type of the method and the given
* <code>returnType</code> aren't equal.
*/
public MethodWrappingFunction(Method method, Class<ReturnType> returnType) throws IllegalArgumentException {
super(isMethodADimension(method));
checkThatReturnTypesMatch(method, returnType);
this.method = method;
this.returnType = returnType;
initializeAdditionalData();
@@ -38,26 +38,29 @@ public class MethodWrappingFunction<ReturnType> extends AbstractFunction<ReturnT
private void checkThatReturnTypesMatch(Method method, Class<ReturnType> returnType) {
if (!method.getReturnType().equals(returnType)) {
throw new IllegalArgumentException("The method return type " + method.getReturnType().getName()
+ " and expected return type " + returnType.getName() + " don't match");
+ " and expected return type " + returnType.getName() + " don't match");
}
}
private void initializeAdditionalData() {
additionalData = new AdditionalMethodWrappingFunctionData("", 0, Integer.MAX_VALUE);
if (method.getAnnotation(Dimension.class) != null) {
Dimension dimensionData = method.getAnnotation(Dimension.class);
additionalData = new AdditionalMethodWrappingFunctionData(dimensionData.messageKey(), 0, dimensionData.ordinal());
additionalData = new AdditionalMethodWrappingFunctionData(dimensionData.messageKey(), 0,
dimensionData.ordinal());
}
if (method.getAnnotation(Statistic.class) != null) {
Statistic statisticData = method.getAnnotation(Statistic.class);
additionalData = new AdditionalMethodWrappingFunctionData(statisticData.messageKey(), statisticData.resultDecimals(), statisticData.ordinal());
additionalData = new AdditionalMethodWrappingFunctionData(statisticData.messageKey(),
statisticData.resultDecimals(), statisticData.ordinal());
}
if (method.getAnnotation(Connector.class) != null) {
Connector connectorData = method.getAnnotation(Connector.class);
additionalData = new AdditionalMethodWrappingFunctionData(connectorData.messageKey(), 0, connectorData.ordinal());
additionalData = new AdditionalMethodWrappingFunctionData(connectorData.messageKey(), 0,
connectorData.ordinal());
}
}
@@ -65,28 +68,29 @@ public class MethodWrappingFunction<ReturnType> extends AbstractFunction<ReturnT
public Class<?> getDeclaringType() {
return method.getDeclaringClass();
}
@Override
public Iterable<Class<?>> getParameters() {
return Arrays.asList(method.getParameterTypes());
}
@Override
public Class<ReturnType> getReturnType() {
return returnType;
}
@Override
public ReturnType tryToInvoke(Object instance) {
return tryToInvoke(instance, new Object[0]);
}
@Override
public ReturnType tryToInvoke(Object instance, ParameterProvider parameterProvider) {
return tryToInvoke(instance, parameterProvider.getParameters());
}
@SuppressWarnings("unchecked") // The cast has to work, because the constructor checks, that the return types match
@SuppressWarnings("unchecked")
// The cast has to work, because the constructor checks, that the return types match
private ReturnType tryToInvoke(Object instance, Object... parameters) {
if (instance != null) {
try {
@@ -102,7 +106,7 @@ public class MethodWrappingFunction<ReturnType> extends AbstractFunction<ReturnT
public int getResultDecimals() {
return additionalData.getResultDecimals();
}
@Override
public int getOrdinal() {
return additionalData.getOrdinal();
@@ -110,32 +114,42 @@ public class MethodWrappingFunction<ReturnType> extends AbstractFunction<ReturnT
@Override
public String getSimpleName() {
return method.getName();
return method.getName() + "(" + parametersAsString() + ")";
}
private String parametersAsString() {
StringBuilder parameterBuilder = new StringBuilder();
boolean first = true;
for (Class<?> parameterType : getParameters()) {
if (!first) {
parameterBuilder.append(", ");
}
parameterBuilder.append(parameterType.getName());
first = false;
}
return parameterBuilder.toString();
}
@Override
public String getLocalizedName(Locale locale, ResourceBundleStringMessages stringMessages) {
if (!isLocalizable()) {
return getSimpleName();
}
String localizedName = "";
if (!additionalData.getMessageKey().isEmpty()) {
localizedName = stringMessages.get(locale, additionalData.getMessageKey());
}
return localizedName;
return stringMessages.get(locale, additionalData.getMessageKey());
}
@Override
public boolean isLocalizable() {
return additionalData != null && (!additionalData.getMessageKey().isEmpty());
}
@Override
public String toString() {
return getDeclaringType().getSimpleName() + "." + method.getName() + "(" + parametersAsString() + ") : " + method.getReturnType().getSimpleName();
return getDeclaringType().getSimpleName() + "." + method.getName() + "(" + parametersAsSimpleString() + ") : "
+ method.getReturnType().getSimpleName();
}
private String parametersAsString() {
private String parametersAsSimpleString() {
StringBuilder parameterBuilder = new StringBuilder();
boolean first = true;
for (Class<?> parameterType : getParameters()) {