提交 3f3218a2 编写于 作者: E Evgeny Fradkin

#60 EE. Mock data template generator

上级 95d85644
......@@ -355,6 +355,15 @@ public class CommonUtils {
return strValue;
}
public static String[] splitWithDelimiter(String s, String delimiter) {
if (s == null) {
return null;
}
String delimiterReplacement = "DRDRDR"; //$NON-NLS-1$
s = s.replace(delimiter, delimiterReplacement + delimiter);
return s.split(delimiterReplacement);
}
@NotNull
public static List<String> splitString(@Nullable String str, char delimiter) {
if (CommonUtils.isEmpty(str)) {
......
......@@ -91,7 +91,7 @@
<type kind="NUMERIC"/>
<propertyGroup label="General">
<property id="start" label="Start value" type="long" defaultValue="0" description="Initial sequence value"/>
<property id="start" label="Start value" type="long" defaultValue="1" description="Initial sequence value"/>
<property id="step" label="Increment step" type="long" defaultValue="1" description="Sequence increment step"/>
<property id="reverse" label="Reverse order" type="boolean" defaultValue="FALSE" description="Reverse the sequence order"/>
</propertyGroup>
......
......@@ -128,4 +128,39 @@ public abstract class AbstractMockValueGenerator implements MockValueGenerator {
return column.getValueEnumeration(session, null, number);
}
protected Boolean getBooleanProperty(Map<Object, Object> properties, String propName) {
Object prop = properties.get(propName);
if (prop != null) {
if (prop instanceof Boolean) {
return (Boolean) prop;
} else {
return Boolean.valueOf(prop.toString());
}
}
return null;
}
protected Double getDoubleProperty(Map<Object, Object> properties, String propName) {
Object prop = properties.get(propName);
if (prop != null) {
if (prop instanceof Double) {
return (Double) prop;
} else {
return Double.valueOf(prop.toString());
}
}
return null;
}
protected Long getLongProperty(Map<Object, Object> properties, String propName) {
Object prop = properties.get(propName);
if (prop != null) {
if (prop instanceof Long) {
return (Long) prop;
} else {
return Long.valueOf(prop.toString());
}
}
return null;
}
}
......@@ -28,22 +28,22 @@ import java.util.Map;
public class NumericSequenceGenerator extends AbstractMockValueGenerator {
private long start = 0;
private long step = 0;
private long start = 1;
private long step = 1;
private boolean reverse = false;
@Override
public void init(DBSDataManipulator container, DBSAttributeBase attribute, Map<Object, Object> properties) throws DBException {
super.init(container, attribute, properties);
Long start = (Long) properties.get("start"); //$NON-NLS-1$
if (start != null) {
this.start = start;
Long startProperty = getLongProperty(properties, "start"); //$NON-NLS-1$
if (startProperty != null) {
this.start = startProperty;
}
Long step = (Long) properties.get("step"); //$NON-NLS-1$
if (step != null) {
this.step = step;
Long stepProperty = getLongProperty(properties, "step"); //$NON-NLS-1$
if (stepProperty != null) {
this.step = stepProperty;
}
Boolean reverse = (Boolean) properties.get("reverse"); //$NON-NLS-1$
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册