public static List<String> makeHierarchy ( final Item item ) { final ItemInformation info = item.getInformation (); if ( info == null ) { return Collections.emptyList (); } return info.getHierarchy (); } }
public AbstractCreationRequest ( final Object component, final List<String> hierarchy ) { this.component = component; this.hierarchy = Collections.unmodifiableList ( new ArrayList<> ( hierarchy ) ); this.itemInformation = OsgiFactory.eINSTANCE.createItemInformation (); this.itemInformation.getHierarchy ().addAll ( this.hierarchy ); this.itemInformation.getIoDirections ().addAll ( IODirection.VALUES ); }
@Override public CreationRequest<T> information ( final String description, final String unit, final String system ) { this.itemInformation.setDescription ( description ); this.itemInformation.setUnit ( unit ); this.itemInformation.setSystem ( system ); return this; }
@Override public CreationRequest<T> request ( final CustomizationRequest request ) { customizationTags ( request.getCustomizationTags () ); localTags ( request.getLocalTags () ); this.globalizationLevel = request.getGlobalizationLevel (); if ( request.getItem ().getInformation () != null ) { this.itemInformation.setDataType ( request.getItem ().getInformation ().getDataType () ); this.itemInformation.setDescription ( request.getItem ().getInformation ().getDescription () ); this.itemInformation.setSystem ( request.getItem ().getInformation ().getSystem () ); } return this; }
public static Map<String, String> createInfoAttributes ( final Item item ) { final Map<String, String> attributes = new HashMap<> (); Configurations.fillAttributesWithHierarchy ( attributes, Names.makeHierarchy ( item ) ); attributes.put ( "item", item.getName () ); if ( item.getInformation () != null ) { addAttribute ( attributes, "system", item.getInformation ().getSystem () ); addAttribute ( attributes, "unit", item.getInformation ().getUnit () ); addAttribute ( attributes, "itemDescription", item.getInformation ().getDescription () ); } return attributes; }
protected void processGroup ( final MasterServer app, final SummaryGroup group, final AbstractComponentItemCreator creator ) { final SummaryItem item = OsgiFactory.eINSTANCE.createSummaryItem (); item.setGroup ( group ); item.setInformation ( OsgiFactory.eINSTANCE.createItemInformation () ); item.getInformation ().setDescription ( String.format ( "Summary group information: %s", Names.makeId ( group ) ) ); item.getInformation ().getHierarchy ().addAll ( Names.makeHierarchy ( group ) ); item.getInformation ().setSystem ( "SCADA" ); final CreationRequest<SummaryItem> c = creator.addItem ( item ); c.localTags ( "SUMMARY" ); c.customizationTags ( "summary" ); final SummaryItem sumItem = c.create (); /* * FIXME: next thing is a bit wonky * actually the summary group should be used for generating sub items * but since the customization process can rename the item, the generator * cannot create a name for this later on. So for now all items * that are SummaryItem will be treated as sub-summary items. */ if ( group.eContainer () instanceof SummaryGroup ) { ( (SummaryGroup)group.eContainer () ).getItems ().add ( sumItem ); } }
private void processExporter ( final DataAccessExporter exporter ) { for ( final ItemExport export : exporter.getExports () ) { final String masterId = Items.makeMasterId ( export.getItem () ); final ItemInformation info = export.getItem ().getInformation (); final String description = info != null ? info.getDescription () : null; addAlias ( Names.makeName ( exporter ) + "/" + export.getExportName (), export.getExportName (), masterId, info.getIoDirections (), description ); } }
/** * 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 = ( (ItemInformation)object ).getDescription (); StyledString styledLabel = new StyledString (); if ( label == null || label.length () == 0 ) { styledLabel.append ( getString ( "_UI_ItemInformation_type" ), StyledString.Style.QUALIFIER_STYLER ); //$NON-NLS-1$ } else { styledLabel.append ( getString ( "_UI_ItemInformation_type" ), StyledString.Style.QUALIFIER_STYLER ).append ( " " + label ); //$NON-NLS-1$ //$NON-NLS-2$ } return styledLabel; }
private void createInternalItem ( final MasterContext masterContext, final String dataSourceId, final String description ) { final WeakReferenceDataSourceItem item = OsgiFactory.eINSTANCE.createWeakReferenceDataSourceItem (); item.setDataSourceId ( dataSourceId ); item.setName ( dataSourceId ); item.setInformation ( OsgiFactory.eINSTANCE.createItemInformation () ); item.getInformation ().setDescription ( description ); item.getInformation ().setSystem ( "SCADA" ); Items.addItem ( masterContext.getImplementation (), item ); }
@Override public CreationRequest<T> direction ( final boolean input, final boolean output ) { this.itemInformation.getIoDirections ().clear (); if ( input ) { this.itemInformation.getIoDirections ().add ( IODirection.INPUT ); } if ( output ) { this.itemInformation.getIoDirections ().add ( IODirection.OUTPUT ); } return this; }
public boolean isType ( final DataType... dataTypes ) { if ( this.item.getInformation () == null ) { return false; } if ( this.item.getInformation ().getDataType () == null ) { return false; } for ( final DataType dataType : dataTypes ) { if ( this.item.getInformation ().getDataType ().equals ( dataType ) ) { return true; } } return false; }
@Override public CreationRequest<T> dataType ( final DataType dataType ) { this.itemInformation.setDataType ( dataType ); return this; }
@Override public CreationRequest<T> request ( final CustomizationRequest request ) { customizationTags ( request.getCustomizationTags () ); localTags ( request.getLocalTags () ); this.globalizationLevel = request.getGlobalizationLevel (); if ( request.getItem ().getInformation () != null ) { this.itemInformation.setDataType ( request.getItem ().getInformation ().getDataType () ); this.itemInformation.setDescription ( request.getItem ().getInformation ().getDescription () ); this.itemInformation.setSystem ( request.getItem ().getInformation ().getSystem () ); } return this; }
public static Map<String, String> createInfoAttributes ( final Item item ) { final Map<String, String> attributes = new HashMap<> (); Configurations.fillAttributesWithHierarchy ( attributes, Names.makeHierarchy ( item ) ); attributes.put ( "item", item.getName () ); if ( item.getInformation () != null ) { addAttribute ( attributes, "system", item.getInformation ().getSystem () ); addAttribute ( attributes, "unit", item.getInformation ().getUnit () ); addAttribute ( attributes, "itemDescription", item.getInformation ().getDescription () ); } return attributes; }
private void processExporter ( final DataAccessExporter exporter ) { for ( final ItemExport export : exporter.getExports () ) { final String masterId = Items.makeMasterId ( export.getItem () ); final ItemInformation info = export.getItem ().getInformation (); final String description = info != null ? info.getDescription () : null; addAlias ( Names.makeName ( exporter ) + "/" + export.getExportName (), export.getExportName (), masterId, info.getIoDirections (), description ); } }
@Override public void generate () { super.generate (); if ( this.item.getConnection () == null ) { throw new IllegalStateException ( String.format ( "Item '%s' has no connection set", this.item.getName () ) ); } addSource ( makeSourceId (), this.item.getSourceName (), Names.makeName ( this.item.getConnection () ), this.item.getInformation ().getDescription () ); }
@Override public CreationRequest<T> direction ( final boolean input, final boolean output ) { this.itemInformation.getIoDirections ().clear (); if ( input ) { this.itemInformation.getIoDirections ().add ( IODirection.INPUT ); } if ( output ) { this.itemInformation.getIoDirections ().add ( IODirection.OUTPUT ); } return this; }
@Override public CreationRequest<T> dataType ( final DataType dataType ) { this.itemInformation.setDataType ( dataType ); return this; }
public static List<String> makeHierarchy ( final Item item ) { final ItemInformation info = item.getInformation (); if ( info == null ) { return Collections.emptyList (); } return info.getHierarchy (); } }
public AbstractCreationRequest ( final Object component, final List<String> hierarchy ) { this.component = component; this.hierarchy = Collections.unmodifiableList ( new ArrayList<> ( hierarchy ) ); this.itemInformation = OsgiFactory.eINSTANCE.createItemInformation (); this.itemInformation.getHierarchy ().addAll ( this.hierarchy ); this.itemInformation.getIoDirections ().addAll ( IODirection.VALUES ); }