which precondition should I add?
gaoxiaolei
New Altair Community Member
Answers
-
Hi,
if I understand what you want, it should looks like this:
It doesn't matter how many attributes ExampleSet have.
inputPort.addPrecondition(new SimplePrecondition(inputPort, new MetaData(
ExampleSet.class)));0 -
Hi, thanks. But my opeator can only cope with exampleset which has only two attributes.StaryVena wrote:
Hi,
if I understand what you want, it should looks like this:
It doesn't matter how many attributes ExampleSet have.
inputPort.addPrecondition(new SimplePrecondition(inputPort, new MetaData(
ExampleSet.class)));
I want this: if a exampleset with more than two attributes, and it connect to my opeator, there should be a error appeard.0 -
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,
Marco0