Skip to content
Snippets Groups Projects
Commit 64defed3 authored by felmer's avatar felmer
Browse files

allow no parent data sets even when index-data-set-parents is defined.

SVN: 12625
parent e7f11eea
No related branches found
No related tags found
No related merge requests found
......@@ -74,10 +74,15 @@ public class DataSetNameEntitiesProvider
* denotes the last entity.
*/
public String getEntity(int index)
{
return getEntity(index, true);
}
String getEntity(int index, boolean throwException)
{
if (index >= entities.length)
{
throwUserFailureException(index + 1);
return emptyStringOrThrowUserFailureException(index + 1, throwException);
}
int actualIndex = index;
if (index < 0)
......@@ -85,17 +90,22 @@ public class DataSetNameEntitiesProvider
actualIndex = entities.length + index;
if (actualIndex < 0)
{
throwUserFailureException(-index);
return emptyStringOrThrowUserFailureException(-index, throwException);
}
}
return entities[actualIndex];
}
private void throwUserFailureException(int expectedNumberOfEntities)
private String emptyStringOrThrowUserFailureException(int expectedNumberOfEntities,
boolean throwException)
{
throw new UserFailureException(errorMessagePrefix + "We need " + expectedNumberOfEntities
+ " entities, separated by '" + entitySeparatorCharacter + "', but got only "
+ entities.length + ".");
if (throwException)
{
throw new UserFailureException(errorMessagePrefix + "We need "
+ expectedNumberOfEntities + " entities, separated by '"
+ entitySeparatorCharacter + "', but got only " + entities.length + ".");
}
return "";
}
}
......@@ -360,7 +360,8 @@ public class DefaultDataSetInfoExtractor extends AbstractDataSetInfoExtractor
{
return Collections.emptyList();
}
String parentDataSetCodes = entitiesProvider.getEntity(indexOfParentDataSetCodes.getIndex());
String parentDataSetCodes =
entitiesProvider.getEntity(indexOfParentDataSetCodes.getIndex(), false);
String[] codes = StringUtils.split(parentDataSetCodes, subEntitySeparator);
return Arrays.asList(codes);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment