mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-08 21:30:57 +00:00
Extracted the domain independent parts of datamining.shared
This commit is contained in:
1 parent
740802071a
commit
56adffdb49
68 files changed
+149
-91
No files matched your search
@@ -5,3 +5,7 @@ Bundle-SymbolicName: com.sap.sse.datamining.shared
|
||||
Bundle-Version: 1.0.0.qualifier
|
||||
Bundle-Vendor: SAP
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
||||
Export-Package: com.sap.sse.datamining.shared,
|
||||
com.sap.sse.datamining.shared.dto,
|
||||
com.sap.sse.datamining.shared.impl,
|
||||
com.sap.sse.datamining.shared.impl.dto
|
||||
@@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<artifactId>root</artifactId>
|
||||
<groupId>com.sap.sse</groupId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>com.sap.sse.datamining.shared</artifactId>
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.eclipse.tycho</groupId>
|
||||
<artifactId>tycho-source-plugin</artifactId>
|
||||
<version>${tycho-version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>plugin-source</id>
|
||||
<phase>generate-sources</phase>
|
||||
<goals>
|
||||
<goal>plugin-source</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.4.0//EN" "http://google-web-toolkit.googlecode.com/svn/tags/2.4.0/distro-source/core/src/gwt-module.dtd">
|
||||
<module>
|
||||
<source path='shared'/>
|
||||
</module>
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package com.sap.sse.datamining.shared;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.sap.sse.datamining.shared.impl.GenericGroupKey;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class DataMiningSerializationDummy implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private GenericGroupKey<String> groupKey;
|
||||
|
||||
private DataMiningSerializationDummy() { }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.sap.sse.datamining.shared;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
public interface GroupKey extends Serializable {
|
||||
|
||||
/**
|
||||
* @return a string representation of this group key.
|
||||
*/
|
||||
public String asString();
|
||||
|
||||
/**
|
||||
* Checks if this group key has a sub key. For example if the data was grouped primary by competitor and secondary by leg type.
|
||||
* @return true, if this group key has a sub key
|
||||
*/
|
||||
public boolean hasSubKey();
|
||||
|
||||
/**
|
||||
* @return the main key, if there is one. Otherwise it returns <code>this</code>.
|
||||
*/
|
||||
public GroupKey getMainKey();
|
||||
|
||||
/**
|
||||
* @return the sub key or null, if there's none.
|
||||
*/
|
||||
public GroupKey getSubKey();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.sap.sse.datamining.shared;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
public interface QueryResult<AggregatedType> extends Serializable {
|
||||
|
||||
int getRetrievedDataAmount();
|
||||
public int getFilteredDataAmount();
|
||||
public double getCalculationTimeInSeconds();
|
||||
|
||||
/**
|
||||
* @return a description what kind of results are contained.
|
||||
*/
|
||||
public String getResultSignifier();
|
||||
|
||||
public Unit getUnit();
|
||||
public int getValueDecimals();
|
||||
|
||||
public boolean isEmpty();
|
||||
public Map<GroupKey, AggregatedType> getResults();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.sap.sse.datamining.shared;
|
||||
|
||||
public enum Unit {
|
||||
|
||||
None, Knots, Meters
|
||||
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package com.sap.sse.datamining.shared.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
public interface FunctionDTO extends Serializable {
|
||||
|
||||
public boolean isDimension();
|
||||
|
||||
public String getDisplayName();
|
||||
|
||||
public List<String> getParameters();
|
||||
|
||||
public String getReturnTypeName();
|
||||
|
||||
public String getSourceTypeName();
|
||||
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package com.sap.sse.datamining.shared.impl;
|
||||
|
||||
import com.sap.sse.datamining.shared.GroupKey;
|
||||
|
||||
|
||||
public abstract class AbstractGroupKey implements GroupKey {
|
||||
private static final long serialVersionUID = 183947887066745315L;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return asString();
|
||||
}
|
||||
|
||||
//Enforce hash code and equals in all subclasses
|
||||
@Override
|
||||
public abstract boolean equals(Object other);
|
||||
@Override
|
||||
public abstract int hashCode();
|
||||
|
||||
}
|
||||
+84
@@ -0,0 +1,84 @@
|
||||
package com.sap.sse.datamining.shared.impl;
|
||||
|
||||
import com.sap.sse.datamining.shared.GroupKey;
|
||||
|
||||
|
||||
public class CompoundGroupKey extends AbstractGroupKey {
|
||||
private static final long serialVersionUID = -7902450253393172550L;
|
||||
|
||||
private GroupKey mainKey;
|
||||
private GroupKey subKey;
|
||||
|
||||
/**
|
||||
* Constructor for the GWT-Serialization. Don't use this!
|
||||
*/
|
||||
@Deprecated
|
||||
CompoundGroupKey() { }
|
||||
|
||||
public CompoundGroupKey(GroupKey mainKey) {
|
||||
this(mainKey, null);
|
||||
}
|
||||
|
||||
public CompoundGroupKey(GroupKey mainKey, GroupKey subKey) {
|
||||
this.mainKey = mainKey;
|
||||
this.subKey = subKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String asString() {
|
||||
return mainKey.asString() + " (" + subKey.asString() + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSubKey() {
|
||||
return subKey != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GroupKey getMainKey() {
|
||||
return mainKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GroupKey getSubKey() {
|
||||
return subKey;
|
||||
}
|
||||
|
||||
public void setSubKey(GroupKey subKey) {
|
||||
this.subKey = subKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((mainKey == null) ? 0 : mainKey.hashCode());
|
||||
result = prime * result + ((subKey == null) ? 0 : subKey.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
CompoundGroupKey other = (CompoundGroupKey) obj;
|
||||
if (mainKey == null) {
|
||||
if (other.mainKey != null)
|
||||
return false;
|
||||
} else if (!mainKey.equals(other.mainKey))
|
||||
return false;
|
||||
if (subKey == null) {
|
||||
if (other.subKey != null)
|
||||
return false;
|
||||
} else if (!subKey.equals(other.subKey))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
package com.sap.sse.datamining.shared.impl;
|
||||
|
||||
import com.sap.sse.datamining.shared.GroupKey;
|
||||
|
||||
|
||||
public class GenericGroupKey<T> extends AbstractGroupKey {
|
||||
private static final long serialVersionUID = -3838535617341226965L;
|
||||
|
||||
private T value;
|
||||
|
||||
/**
|
||||
* Constructor for the GWT-Serialization. Don't use this!
|
||||
*/
|
||||
@Deprecated
|
||||
GenericGroupKey() { }
|
||||
|
||||
public GenericGroupKey(T value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSubKey() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GroupKey getMainKey() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GroupKey getSubKey() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String asString() {
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((value == null) ? 0 : value.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
GenericGroupKey<?> other = (GenericGroupKey<?>) obj;
|
||||
if (value == null) {
|
||||
if (other.value != null)
|
||||
return false;
|
||||
} else if (!value.equals(other.value))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
package com.sap.sse.datamining.shared.impl;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.sap.sse.datamining.shared.GroupKey;
|
||||
import com.sap.sse.datamining.shared.QueryResult;
|
||||
import com.sap.sse.datamining.shared.Unit;
|
||||
|
||||
public class QueryResultImpl<AggregatedType> implements QueryResult<AggregatedType> {
|
||||
private static final long serialVersionUID = -8347731622150585715L;
|
||||
|
||||
private int retrievedDataAmount;
|
||||
private int filteredDataAmount;
|
||||
private long calculationTimeInNanos;
|
||||
|
||||
private String resultSignifier;
|
||||
private Unit unit;
|
||||
private int valueDecimals;
|
||||
|
||||
private Map<GroupKey, AggregatedType> results;
|
||||
|
||||
/**
|
||||
* Constructor for the GWT-Serialization. Don't use this!
|
||||
*/
|
||||
@Deprecated
|
||||
QueryResultImpl() { }
|
||||
|
||||
public QueryResultImpl(int retrievedDataAmount, int filteredDataAmount, String resultSiginifier, Unit unit, int valueDecimals) {
|
||||
this.retrievedDataAmount = retrievedDataAmount;
|
||||
this.filteredDataAmount = filteredDataAmount;
|
||||
results = new HashMap<GroupKey, AggregatedType>();
|
||||
this.resultSignifier = resultSiginifier;
|
||||
this.unit = unit;
|
||||
this.valueDecimals = valueDecimals;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRetrievedDataAmount() {
|
||||
return retrievedDataAmount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFilteredDataAmount() {
|
||||
return filteredDataAmount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getCalculationTimeInSeconds() {
|
||||
return calculationTimeInNanos / 1000000000.0;
|
||||
}
|
||||
|
||||
public void setCalculationTimeInNanos(long calculationTimeInNanos) {
|
||||
this.calculationTimeInNanos = calculationTimeInNanos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return results.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getResultSignifier() {
|
||||
return resultSignifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Unit getUnit() {
|
||||
return unit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getValueDecimals() {
|
||||
return valueDecimals;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<GroupKey, AggregatedType> getResults() {
|
||||
return results;
|
||||
}
|
||||
|
||||
public void addResult(GroupKey key, AggregatedType value) {
|
||||
results.put(key, value);
|
||||
}
|
||||
|
||||
}
|
||||
+125
@@ -0,0 +1,125 @@
|
||||
package com.sap.sse.datamining.shared.impl.dto;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.sap.sse.datamining.shared.dto.FunctionDTO;
|
||||
|
||||
public class FunctionDTOImpl implements FunctionDTO {
|
||||
private static final long serialVersionUID = 4587389541910498505L;
|
||||
|
||||
private String functionName;
|
||||
private String sourceTypeName;
|
||||
private String returnTypeName;
|
||||
private List<String> parameterTypeNames;
|
||||
|
||||
private String displayName;
|
||||
private boolean isDimension;
|
||||
|
||||
/**
|
||||
* Constructor for the GWT-Serialization. Don't use this!
|
||||
*/
|
||||
@Deprecated
|
||||
FunctionDTOImpl() {
|
||||
}
|
||||
|
||||
public FunctionDTOImpl(String functionName, String sourceTypeName, String returnTypeName, List<String> parameterTypeNames, String displayName, boolean isDimension) {
|
||||
this.functionName = functionName;
|
||||
this.sourceTypeName = sourceTypeName;
|
||||
this.returnTypeName = returnTypeName;
|
||||
this.parameterTypeNames = new ArrayList<String>(parameterTypeNames);
|
||||
|
||||
this.displayName = displayName;
|
||||
this.isDimension = isDimension;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSourceTypeName() {
|
||||
return sourceTypeName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getReturnTypeName() {
|
||||
return returnTypeName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getParameters() {
|
||||
return parameterTypeNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDimension() {
|
||||
return isDimension;
|
||||
}
|
||||
|
||||
@Override
|
||||
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();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((functionName == null) ? 0 : functionName.hashCode());
|
||||
result = prime * result + (isDimension ? 1231 : 1237);
|
||||
result = prime * result + ((parameterTypeNames == null) ? 0 : parameterTypeNames.hashCode());
|
||||
result = prime * result + ((returnTypeName == null) ? 0 : returnTypeName.hashCode());
|
||||
result = prime * result + ((sourceTypeName == null) ? 0 : sourceTypeName.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
FunctionDTOImpl other = (FunctionDTOImpl) obj;
|
||||
if (functionName == null) {
|
||||
if (other.functionName != null)
|
||||
return false;
|
||||
} else if (!functionName.equals(other.functionName))
|
||||
return false;
|
||||
if (isDimension != other.isDimension)
|
||||
return false;
|
||||
if (parameterTypeNames == null) {
|
||||
if (other.parameterTypeNames != null)
|
||||
return false;
|
||||
} else if (!parameterTypeNames.equals(other.parameterTypeNames))
|
||||
return false;
|
||||
if (returnTypeName == null) {
|
||||
if (other.returnTypeName != null)
|
||||
return false;
|
||||
} else if (!returnTypeName.equals(other.returnTypeName))
|
||||
return false;
|
||||
if (sourceTypeName == null) {
|
||||
if (other.sourceTypeName != null)
|
||||
return false;
|
||||
} else if (!sourceTypeName.equals(other.sourceTypeName))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user