use of io.syndesis.common.model.bulletin.ConnectionBulletinBoard in project syndesis by syndesisio.
the class ConnectionUpdateHandler method compute.
@Override
protected List<ConnectionBulletinBoard> compute(ChangeEvent event) {
final List<ConnectionBulletinBoard> boards = new ArrayList<>();
final DataManager dataManager = getDataManager();
final List<Connector> connectors = dataManager.fetchAll(Connector.class).getItems();
for (int i = 0; i < connectors.size(); i++) {
final Connector connector = connectors.get(i);
final String id = connector.getId().get();
dataManager.fetchAllByPropertyValue(Connection.class, "connectorId", id).filter(connection -> connection.getConnector().isPresent()).map(connection -> computeBoard(connection, connection.getConnector().get(), connector)).forEach(boards::add);
}
return boards;
}
use of io.syndesis.common.model.bulletin.ConnectionBulletinBoard in project syndesis by syndesisio.
the class ConnectionUpdateHandler method computeBoard.
private ConnectionBulletinBoard computeBoard(Connection connection, Connector oldConnector, Connector newConnector) {
final DataManager dataManager = getDataManager();
final String id = connection.getId().get();
final ConnectionBulletinBoard board = dataManager.fetchByPropertyValue(ConnectionBulletinBoard.class, "targetResourceId", id).orElse(null);
final ConnectionBulletinBoard.Builder builder;
if (board != null) {
builder = new ConnectionBulletinBoard.Builder().createFrom(board).updatedAt(System.currentTimeMillis());
} else {
builder = new ConnectionBulletinBoard.Builder().id(KeyGenerator.createKey()).targetResourceId(id).createdAt(System.currentTimeMillis());
}
List<LeveledMessage> messages = new ArrayList<>();
messages.addAll(computeValidatorMessages(LeveledMessage.Builder::new, connection));
messages.addAll(computePropertiesDiffMessages(LeveledMessage.Builder::new, oldConnector.getProperties(), newConnector.getProperties()));
messages.addAll(computeMissingMandatoryPropertiesMessages(LeveledMessage.Builder::new, newConnector.getProperties(), connection.getConfiguredProperties()));
messages.addAll(computeSecretsUpdateMessages(LeveledMessage.Builder::new, newConnector.getProperties(), connection.getConfiguredProperties()));
builder.errors(countMessagesWithLevel(LeveledMessage.Level.ERROR, messages));
builder.warnings(countMessagesWithLevel(LeveledMessage.Level.WARN, messages));
builder.notices(countMessagesWithLevel(LeveledMessage.Level.INFO, messages));
builder.putMetadata("connector-id", newConnector.getId().get());
builder.putMetadata("connector-version-latest", Integer.toString(newConnector.getVersion()));
builder.putMetadata("connector-version-connection", Integer.toString(oldConnector.getVersion()));
builder.messages(messages);
return builder.build();
}
Aggregations