public void process () { for ( final Item item : this.app.getItems () ) { processItem ( item ); } }
private static DataAccessConnection findConnection ( final MasterServer from, final MasterServer to ) { for ( final org.eclipse.scada.configuration.world.osgi.Connection c : from.getConnections () ) { if ( ! ( c instanceof DataAccessConnection ) ) { continue; } for ( final Exporter e : to.getExporter () ) { final Endpoint ep = c.getMatchingEndpoint ( e ); if ( ep != null ) { // this is a common endpoing of the connection and the exporter return (DataAccessConnection)c; } } } return null; }
private void createServerInformation () { final String prefix = this.app.getAeServerInformationPrefix (); if ( prefix != null && !prefix.isEmpty () ) { final Map<String, String> data = new HashMap<String, String> ( 1 ); data.put ( "prefix", prefix ); //$NON-NLS-1$ addData ( Factories.FACTORY_AE_SERVER_INFO, prefix, data ); } }
public void process () { for ( final Average average : this.app.getAverages () ) { createAverage ( average ); } for ( final MovingAverage average : this.app.getMovingAverages () ) { createMovingAverage ( average ); } }
private <T extends Connection> T createConnection ( final EClass connectionClass, final Class<T> clazz, final Global global, final Local local ) { final T connection = clazz.cast ( OsgiFactory.eINSTANCE.create ( connectionClass ) ); final String tag = connection.getTypeTag (); final String cname = String.format ( "global.%s.to.%s.%s", Names.makeName ( global.getGlobal () ), local.getId (), tag ); connection.setName ( cname ); // set credentials connection.setCredentials ( EcoreUtil.copy ( findCredentials ( global, local ) ) ); // add connection to "from" global.getGlobal ().getConnections ().add ( connection ); // point connection to "to" final LinkedList<Endpoint> endpoints = new LinkedList<> (); for ( final Exporter exporter : local.getLocal ().getExporter () ) { endpoints.addAll ( connection.getPossibleEndpoints ( exporter ) ); } if ( endpoints.isEmpty () ) { throw new IllegalStateException ( String.format ( "Unable to find an exporter that could serve as endpoint for connection type %s on master %s", connectionClass.getName (), local.getLocal ().getName () ) ); } final Endpoint endpoint = endpoints.getFirst (); connection.setEndpoint ( endpoint ); // FIXME: adding connection analyzers to "app", in phase 1 return connection; }
public static void addItem ( final MasterServer master, final Item item ) { // adding item master.getItems ().add ( item ); // export item on all DA exporters for ( final Exporter exporter : master.getExporter () ) { if ( exporter instanceof DataAccessExporter ) { final ItemExport itemExport = OsgiFactory.eINSTANCE.createItemExport (); itemExport.setExportName ( item.getName () ); itemExport.setItem ( item ); ( (DataAccessExporter)exporter ).getExports ().add ( itemExport ); } } }
for ( final Item item : app.getItems () ) if ( app.getMarkers () == null ) app.setMarkers ( OsgiFactory.eINSTANCE.createMarkers () ); app.getMarkers ().getMarkerGroups ().add ( markerGroup );
public void process () { createServerInformation (); for ( final MonitorPool pool : this.app.getMonitorPools () ) { createMonitorPool ( pool ); } for ( final EventPool pool : this.app.getEventPools () ) { createEventPool ( pool ); } for ( final ExternalEventMonitor eventMonitor : this.app.getExternalEventMonitors () ) { createExternalEventMonitor ( eventMonitor ); } createExternalFilters (); }
public static Connection findConnection ( final MasterServer master, final String name, final Class<DataAccessConnection> clazz ) { for ( final Connection c : master.getConnections () ) { if ( !clazz.isAssignableFrom ( c.getClass () ) ) { continue; } if ( c.getName ().equals ( name ) ) { return c; } } throw new IllegalStateException ( String.format ( "Unable to find a connection named '%s' of ype %s on %s", name, clazz.getName (), master ) ); }
public static void setSourceConnectionFromEndpoints ( final SourceItem item, final MasterServer master, final Collection<Endpoint> endpoints ) { final Connection connection = Locator.findConnection ( master, endpoints ); if ( connection == null ) { final String nodeName = Nodes.makeName ( Nodes.fromApp ( master ) ); throw new IllegalStateException ( String.format ( "Master '%s' on node '%s' does not have a connection to endpoints %s", master.getName (), nodeName, StringHelper.join ( endpoints, ", " ) ) ); } if ( ! ( connection instanceof DataAccessConnection ) ) { throw new IllegalStateException ( String.format ( "Connection is of type %s but must be of type %s (Endpoints: %s)", connection.getClass ().getName (), DataAccessConnection.class.getName (), StringHelper.join ( endpoints, ", " ) ) ); } item.setConnection ( (DataAccessConnection)connection ); }
public void process () { for ( BufferedValue bufferedValue : app.getBufferedValues () ) { addBufferedValue ( bufferedValue ); } }
public static <T extends Exporter> List<T> findExporters ( final EObject start, final Class<T> clazz ) { if ( ! ( start.eContainer () instanceof MasterServer ) ) { return null; } final List<T> result = new LinkedList<> (); for ( final Exporter exporter : ( (MasterServer)start.eContainer () ).getExporter () ) { if ( clazz.isAssignableFrom ( exporter.getClass () ) ) { result.add ( clazz.cast ( exporter ) ); } } return result; }
public void process () { for ( final DataMapper dataMapper : this.app.getDataMapper () ) { if ( dataMapper instanceof SimpleDataMapper ) { processSimple ( (SimpleDataMapper)dataMapper ); } else if ( dataMapper instanceof JdbcDataMapper ) { processJdbc ( (JdbcDataMapper)dataMapper ); } } }
public void process () { if ( this.app.getMarkers () == null ) { return; } for ( final MarkerGroup group : this.app.getMarkers ().getMarkerGroups () ) { final Map<String, String> attributes = new HashMap<> (); addMarker ( group.getName (), group.getItems (), group.getMarkers (), attributes ); } }
@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" ); } }
if ( events.isIncludeLocal () ) eventProxy.getLocal ().addAll ( global.getGlobal ().getEventPools () ); for ( final EventPool localPool : local.getLocal ().getEventPools () )
public static void addItem ( final MasterServer master, final Item item ) { // adding item master.getItems ().add ( item ); // export item on all DA exporters for ( final Exporter exporter : master.getExporter () ) { if ( exporter instanceof DataAccessExporter ) { final ItemExport itemExport = OsgiFactory.eINSTANCE.createItemExport (); itemExport.setExportName ( item.getName () ); itemExport.setItem ( item ); ( (DataAccessExporter)exporter ).getExports ().add ( itemExport ); } } }
public void process () { createServerInformation (); for ( final MonitorPool pool : this.app.getMonitorPools () ) { createMonitorPool ( pool ); } for ( final EventPool pool : this.app.getEventPools () ) { createEventPool ( pool ); } for ( final ExternalEventMonitor eventMonitor : this.app.getExternalEventMonitors () ) { createExternalEventMonitor ( eventMonitor ); } createExternalFilters (); }
public static Connection findConnection ( final MasterServer master, final String name, final Class<DataAccessConnection> clazz ) { for ( final Connection c : master.getConnections () ) { if ( !clazz.isAssignableFrom ( c.getClass () ) ) { continue; } if ( c.getName ().equals ( name ) ) { return c; } } throw new IllegalStateException ( String.format ( "Unable to find a connection named '%s' of ype %s on %s", name, clazz.getName (), master ) ); }
public void process () { for ( final Average average : this.app.getAverages () ) { createAverage ( average ); } for ( final MovingAverage average : this.app.getMovingAverages () ) { createMovingAverage ( average ); } }