Search in sources :

Example 1 with ConnectionOverview

use of io.syndesis.common.model.connection.ConnectionOverview in project syndesis by syndesisio.

the class ConnectionHandler method list.

@Override
public ListResult<ConnectionOverview> list(@Context UriInfo uriInfo) {
    final DataManager dataManager = getDataManager();
    final ListResult<Connection> connections = fetchAll(Connection.class, uriInfo);
    final List<ConnectionOverview> overviews = new ArrayList<>(connections.getTotalCount());
    for (Connection connection : connections.getItems()) {
        final String id = connection.getId().get();
        final ConnectionOverview.Builder builder = new ConnectionOverview.Builder().createFrom(connection);
        // set the connector
        DataManagerSupport.fetch(dataManager, Connector.class, connection.getConnectorId()).ifPresent(builder::connector);
        // set the board
        DataManagerSupport.fetchBoard(dataManager, ConnectionBulletinBoard.class, id).ifPresent(builder::board);
        overviews.add(builder.build());
    }
    return ListResult.of(overviews);
}
Also used : Connector(io.syndesis.common.model.connection.Connector) ConnectionOverview(io.syndesis.common.model.connection.ConnectionOverview) Connection(io.syndesis.common.model.connection.Connection) ArrayList(java.util.ArrayList) DataManager(io.syndesis.server.dao.manager.DataManager) ConnectionBulletinBoard(io.syndesis.common.model.bulletin.ConnectionBulletinBoard)

Example 2 with ConnectionOverview

use of io.syndesis.common.model.connection.ConnectionOverview in project syndesis by syndesisio.

the class ConnectionHandler method get.

@Override
public ConnectionOverview get(final String id) {
    final DataManager dataManager = getDataManager();
    final Connection connection = dataManager.fetch(Connection.class, id);
    if (connection == null) {
        throw new EntityNotFoundException();
    }
    final ConnectionOverview.Builder builder = new ConnectionOverview.Builder().createFrom(connection);
    // set the connector
    DataManagerSupport.fetch(dataManager, Connector.class, connection.getConnectorId()).ifPresent(builder::connector);
    // set the board
    DataManagerSupport.fetchBoard(dataManager, ConnectionBulletinBoard.class, id).ifPresent(builder::board);
    return builder.build();
}
Also used : Connector(io.syndesis.common.model.connection.Connector) ConnectionOverview(io.syndesis.common.model.connection.ConnectionOverview) Connection(io.syndesis.common.model.connection.Connection) DataManager(io.syndesis.server.dao.manager.DataManager) EntityNotFoundException(javax.persistence.EntityNotFoundException) ConnectionBulletinBoard(io.syndesis.common.model.bulletin.ConnectionBulletinBoard)

Aggregations

ConnectionBulletinBoard (io.syndesis.common.model.bulletin.ConnectionBulletinBoard)2 Connection (io.syndesis.common.model.connection.Connection)2 ConnectionOverview (io.syndesis.common.model.connection.ConnectionOverview)2 Connector (io.syndesis.common.model.connection.Connector)2 DataManager (io.syndesis.server.dao.manager.DataManager)2 ArrayList (java.util.ArrayList)1 EntityNotFoundException (javax.persistence.EntityNotFoundException)1