The Altair Community is migrating to a new platform to provide a better experience for you. In preparation for the migration, the Altair Community is on read-only mode from October 28 - November 6, 2024. Technical support via cases will continue to work as is. For any urgent requests from Students/Faculty members, please submit the form linked here
Problem in AttributeRole
vahid_erad
Member Posts: 2 Contributor I
@OverrideWhat is worng in the code??
public void doWork() throws OperatorException
{
File file = getParameterAsFile("example_set_file");
ExampleSet eSet = exampleSetInput.getData();
try
{
Attribute sum = AttributeFactory.createAttribute("sum", Attributes.SPECIAL);
eSet.getExampleTable().addAttribute(sum);
eSet.getAttributes().add(eSet.getAttributes().findRoleByName("id"));
}
catch (IOException e)
{
throw new UserError(this, 303, file, e.getMessage());
}
exampleSetOutput.deliver(eSet);
}
Tagged:
0
Answers
what should be the problem with this code? Do you get an error when you are trying to compile it?
Or does it behave unexpectedly?
Best,
Nils
In this line i have error
<Code>eSet.getAttributes().add(eSet.getAttributes().findRoleByName("id"));</Code>
I can't set the attribute to ID role
You are getting the current ID Attribute and try to set it again. This does not work.
If you want to set 'sum' as ID Attribute use this function Best,
Nils