entity = tok.nextToken();
field = tok.nextToken();
}
else
{
throw new MolgenisModelException("field with name '" + f + " is unknown" + tok.countTokens());
}
// get entity
Field result = null;
if (entity != null)
{
Entity em;
try
{
// todo: make case insensitive?
em = this.getEntity(entity);
}
catch (Exception e)
{
throw new MolgenisModelException("field with name '" + f + " is unknown: " + e.getMessage());
}
// get field
result = em.getAllField(field);
}
else
{
int count = 0;
for (Entity em : getEntities())
{
for (Field fm : em.getAllFields())
{
if (fm.getName().equalsIgnoreCase(field))
{
result = fm;
count++;
if (count > 1) throw new MolgenisModelException("field with name '" + f
+ " is not unique, please provide entity also in format {entity}.{field}");
}
}
}
}
if (result != null)
{
return result;
}
else
{
throw new MolgenisModelException("field with name '" + f + "' is unknown: ");
}
}