🎉Community Raffle - Win $25

An exclusive raffle opportunity for active members like you! Complete your profile, answer questions and get your first accepted badge to enter the raffle.
Join and Win

Problem in AttributeRole

User: "vahid_erad"
New Altair Community Member
Updated by Jocelyn
@Override
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);
}
What is worng in the code??

Find more posts tagged with

Sort by:
1 - 3 of 31
    User: "Nils_Woehler"
    New Altair Community Member
    Hi,

    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
    User: "vahid_erad"
    New Altair Community Member
    OP
    I have a error
    In this line i have error

    <Code>eSet.getAttributes().add(eSet.getAttributes().findRoleByName("id"));</Code>

    I can't set the attribute to ID role
    User: "Nils_Woehler"
    New Altair Community Member
    What's the purpose of this line?
    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

    setSpecialAttribute(Attribute attribute, String specialName)
    Best,
    Nils