private void createConnection ( final Connection connection ) { final Map<String, String> data = new HashMap<> ( 1 ); final String configurationId = Names.makeName ( connection ); final Endpoint ep = connection.getEndpoint (); final boolean isLocal = Nodes.isLocal ( ep.getNode (), this.app ); data.put ( "connection.uri", connection.makeUri ( isLocal ) ); //$NON-NLS-1$ addData ( connection.getFactoryId (), configurationId, data ); } }
@Override public void setMaster ( final SourceItem item, final MasterContext master ) { final Connection connection = this.connectionProvider.getConnection ( master.getImplementation () ); final String tag = connection.getTypeTag (); final String id = connection.getName (); item.setSourceName ( String.format ( this.format, tag, id ) ); } }
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; }
/** * Find all connections of the give type from master server <q>from</q> to * master server <q>to</q> */ public static <T extends Connection> List<T> findPossibleConnections ( final EquinoxApplication from, final EquinoxApplication to, final Class<T> clazz ) { final List<T> result = new LinkedList<> (); for ( final T connection : findConnections ( from, clazz ) ) { for ( final Exporter exporter : to.getExporter () ) { final EList<Endpoint> possibleEndpoints = connection.getPossibleEndpoints ( exporter ); if ( possibleEndpoints.isEmpty () ) { continue; } if ( possibleEndpoints.contains ( connection.getEndpoint () ) ) { result.add ( connection ); } } } return result; }
public static Connection findConnection ( final EquinoxApplication source, final Collection<Endpoint> target ) { if ( source == null ) { return null; } for ( final Endpoint ep : target ) { for ( final Connection connection : source.getConnections () ) { if ( connection.getEndpoint () == null ) { continue; } if ( connection.getEndpoint ().equals ( ep ) ) { return connection; } } } return null; }
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 ) ); }
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; }
/** * Find all connections of the give type from master server <q>from</q> to * master server <q>to</q> */ public static <T extends Connection> List<T> findPossibleConnections ( final EquinoxApplication from, final EquinoxApplication to, final Class<T> clazz ) { final List<T> result = new LinkedList<> (); for ( final T connection : findConnections ( from, clazz ) ) { for ( final Exporter exporter : to.getExporter () ) { final EList<Endpoint> possibleEndpoints = connection.getPossibleEndpoints ( exporter ); if ( possibleEndpoints.isEmpty () ) { continue; } if ( possibleEndpoints.contains ( connection.getEndpoint () ) ) { result.add ( connection ); } } } return result; }
public static Connection findConnection ( final EquinoxApplication source, final Collection<Endpoint> target ) { if ( source == null ) { return null; } for ( final Endpoint ep : target ) { for ( final Connection connection : source.getConnections () ) { if ( connection.getEndpoint () == null ) { continue; } if ( connection.getEndpoint ().equals ( ep ) ) { return connection; } } } return null; }
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 ) ); }
private void createConnection ( final Connection connection ) { final Map<String, String> data = new HashMap<> ( 1 ); final String configurationId = Names.makeName ( connection ); final Endpoint ep = connection.getEndpoint (); final boolean isLocal = Nodes.isLocal ( ep.getNode (), this.app ); data.put ( "connection.uri", connection.makeUri ( isLocal ) ); //$NON-NLS-1$ addData ( connection.getFactoryId (), configurationId, data ); } }
final Exporter exporter = map.get ( con.getEndpoint () ); logger.debug ( "Connection points to - exporter: {}, endpoint: {}", exporter.getName (), con.getEndpoint ().getName () ); result.add ( con.getEndpoint () );
/** * 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 = ( (Connection)object ).getName (); StyledString styledLabel = new StyledString (); if ( label == null || label.length () == 0 ) { styledLabel.append ( getString ( "_UI_Connection_type" ), StyledString.Style.QUALIFIER_STYLER ); //$NON-NLS-1$ } else { styledLabel.append ( getString ( "_UI_Connection_type" ), StyledString.Style.QUALIFIER_STYLER ).append ( " " + label ); //$NON-NLS-1$ //$NON-NLS-2$ } return styledLabel; }
final Exporter exporter = map.get ( con.getEndpoint () ); logger.debug ( "Connection points to - exporter: {}, endpoint: {}", exporter.getName (), con.getEndpoint ().getName () ); result.add ( con.getEndpoint () );