public static InputDefinition findSingleInputByName ( final Collection<InputDefinition> defs, final String name ) { for ( final InputDefinition def : defs ) { if ( name.equals ( def.getName () ) ) { return def; } } throw new IllegalArgumentException ( String.format ( "Unable to find an input named '%s'", name ) ); }
@Override protected void generateForMaster ( GenerationContext context, MasterContext master ) { BufferedValue bufferedValueGenerated = OsgiFactory.eINSTANCE.createBufferedValue (); bufferedValueGenerated.setName ( this.bufferedValue.getName () ); if ( this.bufferedValue.getInput () != null ) { final ItemReference ref = OsgiFactory.eINSTANCE.createItemReference (); ref.setName ( this.bufferedValue.getInput ().getName () ); ref.setItem ( this.bufferedValue.getInput ().createReference () ); bufferedValueGenerated.setItem ( ref ); bufferedValueGenerated.setShortDescription ( String.format ( "buffers item '%s' for %ss and is triggered every %ss", this.bufferedValue.getInput ().getName (), this.bufferedValue.getRange () / 1000, this.bufferedValue.getTrigger () ) ); } if ( this.bufferedValue.getInitialValue () != null ) { bufferedValueGenerated.setInitialValue ( this.bufferedValue.getInitialValue () ); } bufferedValueGenerated.setPersistence ( Persistence.getByName ( this.bufferedValue.getPersistence ().getName () ) ); bufferedValueGenerated.setRange ( this.bufferedValue.getRange () ); bufferedValueGenerated.setTrigger ( this.bufferedValue.getTrigger () ); bufferedValueGenerated.setTriggerOnly ( this.bufferedValue.isTriggerOnly () ); master.getImplementation ().getBufferedValues ().add ( bufferedValueGenerated ); danglingBufferedValues.put ( master.getImplementation (), bufferedValueGenerated ); super.generateForMaster ( context, master ); }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public InputDefinition getInput () { if ( input != null && input.eIsProxy () ) { InternalEObject oldInput = (InternalEObject)input; input = (InputDefinition)eResolveProxy ( oldInput ); if ( input != oldInput ) { InternalEObject newInput = (InternalEObject)input; NotificationChain msgs = oldInput.eInverseRemove ( this, EOPPOSITE_FEATURE_BASE - ComponentPackage.BUFFERED_VALUE__INPUT, null, null ); if ( newInput.eInternalContainer () == null ) { msgs = newInput.eInverseAdd ( this, EOPPOSITE_FEATURE_BASE - ComponentPackage.BUFFERED_VALUE__INPUT, null, msgs ); } if ( msgs != null ) msgs.dispatch (); if ( eNotificationRequired () ) eNotify ( new ENotificationImpl ( this, Notification.RESOLVE, ComponentPackage.BUFFERED_VALUE__INPUT, oldInput, input ) ); } } return input; }
@Override protected void generateForMaster ( final GenerationContext context, final MasterContext master, final AverageModule implementation ) { final Average average = OsgiFactory.eINSTANCE.createAverage (); average.setName ( makeId () ); master.getImplementation ().getAverages ().add ( average ); average.setSourcesRequired ( implementation.getValidSourcesRequired () ); this.map.put ( master.getImplementation (), average ); this.danglingMap.put ( master.getImplementation (), average ); for ( final InputDefinition input : Calculations.findByName ( this.calculationComponent.getInputs (), "input" ) ) { average.getItems ().add ( input.createReference () ); } if ( average.getItems ().isEmpty () ) { throw new IllegalStateException ( "Average must contain more than at least one item" ); } }
typedRef.setItem ( input.createReference () ); typedRef.setName ( input.getName () );
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public InputDefinition getSource () { if ( source != null && source.eIsProxy () ) { InternalEObject oldSource = (InternalEObject)source; source = (InputDefinition)eResolveProxy ( oldSource ); if ( source != oldSource ) { InternalEObject newSource = (InternalEObject)source; NotificationChain msgs = oldSource.eInverseRemove ( this, EOPPOSITE_FEATURE_BASE - ComponentPackage.DELTA_VALUE__SOURCE, null, null ); if ( newSource.eInternalContainer () == null ) { msgs = newSource.eInverseAdd ( this, EOPPOSITE_FEATURE_BASE - ComponentPackage.DELTA_VALUE__SOURCE, null, msgs ); } if ( msgs != null ) msgs.dispatch (); if ( eNotificationRequired () ) eNotify ( new ENotificationImpl ( this, Notification.RESOLVE, ComponentPackage.DELTA_VALUE__SOURCE, oldSource, source ) ); } } return source; }
@Override protected CreationRequest<?> createRequest ( final ItemCreator itemCreator ) { final DeltaItem item = OsgiFactory.eINSTANCE.createDeltaItem (); item.setSource ( this.deltaValue.getSource ().createReference () ); final CreationRequest<DeltaItem> req = itemCreator.addItem ( item ); req.addMasterListener ( new MasterListener<DeltaItem> () { @Override public void setMaster ( final DeltaItem item, final MasterContext master ) { DeltaValueGenerator.this.items.put ( master.getImplementation (), item ); } } ); return req; }
itemRef.setItem ( input.createReference () ); itemRef.setName ( input.getName () );
public static List<InputDefinition> findByName ( final Collection<InputDefinition> defs, final String name ) { if ( name == null ) { return Collections.emptyList (); } final List<InputDefinition> result = new LinkedList<> (); for ( final InputDefinition def : defs ) { if ( name.equals ( def.getName () ) ) { result.add ( def ); } } return result; }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public InputDefinition getInput () { if ( input != null && input.eIsProxy () ) { InternalEObject oldInput = (InternalEObject)input; input = (InputDefinition)eResolveProxy ( oldInput ); if ( input != oldInput ) { InternalEObject newInput = (InternalEObject)input; NotificationChain msgs = oldInput.eInverseRemove ( this, EOPPOSITE_FEATURE_BASE - ComponentPackage.MAPPED_SOURCE_VALUE__INPUT, null, null ); if ( newInput.eInternalContainer () == null ) { msgs = newInput.eInverseAdd ( this, EOPPOSITE_FEATURE_BASE - ComponentPackage.MAPPED_SOURCE_VALUE__INPUT, null, msgs ); } if ( msgs != null ) msgs.dispatch (); if ( eNotificationRequired () ) eNotify ( new ENotificationImpl ( this, Notification.RESOLVE, ComponentPackage.MAPPED_SOURCE_VALUE__INPUT, oldInput, input ) ); } } return input; }
@Override public void createItems ( final ItemCreator itemCreator ) { final DanglingItemReference source = this.mappedSourceValue.getInput ().createReference (); final CreationRequest<ReferenceItem> c = itemCreator.createReferenceItem ( source ); c.customizationTags ( this.mappedSourceValue.getCustomizationTags () ); c.localTags ( this.mappedSourceValue.getName () ); c.dataType ( this.mappedSourceValue.getDataType () ); final ReferenceItem item = c.create (); this.refs.add ( item ); }
/** * This returns the label styled text for the adapted class. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public Object getStyledText ( Object object ) { String label = ( (InputDefinition)object ).getName (); StyledString styledLabel = new StyledString (); if ( label == null || label.length () == 0 ) { styledLabel.append ( getString ( "_UI_InputDefinition_type" ), StyledString.Style.QUALIFIER_STYLER ); //$NON-NLS-1$ } else { styledLabel.append ( getString ( "_UI_InputDefinition_type" ), StyledString.Style.QUALIFIER_STYLER ).append ( " " + label ); //$NON-NLS-1$ //$NON-NLS-2$ } return styledLabel; }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public InputDefinition getInput () { if ( input != null && input.eIsProxy () ) { InternalEObject oldInput = (InternalEObject)input; input = (InputDefinition)eResolveProxy ( oldInput ); if ( input != oldInput ) { InternalEObject newInput = (InternalEObject)input; NotificationChain msgs = oldInput.eInverseRemove ( this, EOPPOSITE_FEATURE_BASE - ComponentPackage.BUFFERED_VALUE__INPUT, null, null ); if ( newInput.eInternalContainer () == null ) { msgs = newInput.eInverseAdd ( this, EOPPOSITE_FEATURE_BASE - ComponentPackage.BUFFERED_VALUE__INPUT, null, msgs ); } if ( msgs != null ) msgs.dispatch (); if ( eNotificationRequired () ) eNotify ( new ENotificationImpl ( this, Notification.RESOLVE, ComponentPackage.BUFFERED_VALUE__INPUT, oldInput, input ) ); } } return input; }
@Override protected void generateForMaster ( final GenerationContext context, final MasterContext master, final MovingAverageModule implementation ) { final MovingAverage average = OsgiFactory.eINSTANCE.createMovingAverage (); average.setName ( makeId () ); master.getImplementation ().getMovingAverages ().add ( average ); average.setNullRange ( implementation.getNullRange () ); average.setRange ( implementation.getRange () ); average.setTrigger ( implementation.getTrigger () ); average.setTriggerOnly ( implementation.isTriggerOnly () ); this.map.put ( master.getImplementation (), average ); this.danglingMap.put ( master.getImplementation (), average ); final InputDefinition input = Calculations.findSingleInputByName ( this.calculationComponent.getInputs (), "input" ); if ( input == null ) { throw new IllegalStateException ( "Moving average must contain have an input item set" ); } average.setItem ( input.createReference () ); }
/** * This returns the label styled text for the adapted class. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public Object getStyledText ( Object object ) { String label = ( (InputDefinition)object ).getName (); StyledString styledLabel = new StyledString (); if ( label == null || label.length () == 0 ) { styledLabel.append ( getString ( "_UI_InputDefinition_type" ), StyledString.Style.QUALIFIER_STYLER ); //$NON-NLS-1$ } else { styledLabel.append ( getString ( "_UI_InputDefinition_type" ), StyledString.Style.QUALIFIER_STYLER ).append ( " " + label ); //$NON-NLS-1$ //$NON-NLS-2$ } return styledLabel; }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public InputDefinition getSource () { if ( source != null && source.eIsProxy () ) { InternalEObject oldSource = (InternalEObject)source; source = (InputDefinition)eResolveProxy ( oldSource ); if ( source != oldSource ) { InternalEObject newSource = (InternalEObject)source; NotificationChain msgs = oldSource.eInverseRemove ( this, EOPPOSITE_FEATURE_BASE - ComponentPackage.DELTA_VALUE__SOURCE, null, null ); if ( newSource.eInternalContainer () == null ) { msgs = newSource.eInverseAdd ( this, EOPPOSITE_FEATURE_BASE - ComponentPackage.DELTA_VALUE__SOURCE, null, msgs ); } if ( msgs != null ) msgs.dispatch (); if ( eNotificationRequired () ) eNotify ( new ENotificationImpl ( this, Notification.RESOLVE, ComponentPackage.DELTA_VALUE__SOURCE, oldSource, source ) ); } } return source; }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public InputDefinition getInput () { if ( input != null && input.eIsProxy () ) { InternalEObject oldInput = (InternalEObject)input; input = (InputDefinition)eResolveProxy ( oldInput ); if ( input != oldInput ) { InternalEObject newInput = (InternalEObject)input; NotificationChain msgs = oldInput.eInverseRemove ( this, EOPPOSITE_FEATURE_BASE - ComponentPackage.MAPPED_SOURCE_VALUE__INPUT, null, null ); if ( newInput.eInternalContainer () == null ) { msgs = newInput.eInverseAdd ( this, EOPPOSITE_FEATURE_BASE - ComponentPackage.MAPPED_SOURCE_VALUE__INPUT, null, msgs ); } if ( msgs != null ) msgs.dispatch (); if ( eNotificationRequired () ) eNotify ( new ENotificationImpl ( this, Notification.RESOLVE, ComponentPackage.MAPPED_SOURCE_VALUE__INPUT, oldInput, input ) ); } } return input; }