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

which precondition should I add?

gaoxiaoleigaoxiaolei Member Posts: 12 Contributor II
edited November 2018 in Help
Hi, everyone.

I developed a operator. This operator can only deal with exampleset has two attributes. I do not konw which precondition should I add to this operator. Could you help me?

Thanks.
gaoxiaolei
Tagged:

Answers

  • StaryVenaStaryVena Member Posts: 126 Contributor II
    Hi,
    if I understand what you want, it should looks like this:

    inputPort.addPrecondition(new SimplePrecondition(inputPort, new MetaData(
    ExampleSet.class)));
    It doesn't matter how many attributes ExampleSet have.
  • gaoxiaoleigaoxiaolei Member Posts: 12 Contributor II
    StaryVena wrote:

    Hi,
    if I understand what you want, it should looks like this:

    inputPort.addPrecondition(new SimplePrecondition(inputPort, new MetaData(
    ExampleSet.class)));
    It doesn't matter how many attributes ExampleSet have.
    Hi, thanks. But my opeator can only cope with exampleset which has only two attributes.
    I want this: if a exampleset with more than two attributes, and it connect to my opeator, there should be a error appeard.
  • Marco_BoeckMarco_Boeck Administrator, Moderator, Employee-RapidMiner, Member, University Professor Posts: 1,996 RM Engineering
    Hi,

    there are a couple of ways to achieve this, for example you can use the already mentioned SimplePrecondition class:

    inputPort.addPrecondition(new SimplePrecondition(inputPort, new MetaData(ExampleSet.class), true) {

    @Override
    /** Override this method to make additional checks. The default implementation does nothing. */
    public void makeAdditionalChecks(MetaData received) {
    if (((ExampleSetMetaData)received).getAllAttributes().size() != 2) {
    inputPort.addError(new SimpleMetaDataError(Severity.ERROR, inputPort, "I18N.key"));
    }
    }
    });

    Regards,
    Marco
Sign In or Register to comment.