use of io.lumeer.api.model.Sequence in project engine by Lumeer.
the class MongoSequenceDao method resetSequence.
@Override
public synchronized void resetSequence(final String indexName) {
final FindOneAndUpdateOptions options = new FindOneAndUpdateOptions().returnDocument(ReturnDocument.AFTER).upsert(true);
final Sequence sequence = new Sequence(indexName, 0);
Bson update = new org.bson.Document("$set", sequence);
databaseCollection().findOneAndUpdate(eq(SequenceCodec.NAME, indexName), update, options);
}
use of io.lumeer.api.model.Sequence in project engine by Lumeer.
the class SequenceCodec method convertFromDocument.
private static Sequence convertFromDocument(final Document bson) {
String id = bson.get(ID) != null ? bson.getObjectId(ID).toHexString() : null;
String name = bson.getString(NAME);
int seq = bson.getInteger(SEQ);
Sequence sequence = new Sequence(name, seq);
sequence.setId(id);
return sequence;
}
use of io.lumeer.api.model.Sequence in project engine by Lumeer.
the class AbstractContextualTask method sendPushNotifications.
public void sendPushNotifications(final String sequenceName) {
final Sequence sequence = getDaoContextSnapshot().getSequenceDao().getSequence(sequenceName);
final Set<String> techManagers = permissionAdapter.getProjectUsersByRole(daoContextSnapshot.getOrganization(), daoContextSnapshot.getProject(), RoleType.TechConfig);
final List<Event> events = new ArrayList<>();
techManagers.forEach(manager -> events.add(createEventForSequence(sequence, manager)));
getPusherClient().trigger(events);
}
use of io.lumeer.api.model.Sequence in project engine by Lumeer.
the class SequenceCreator method createSequences.
private void createSequences() {
final JSONArray sequences = (JSONArray) templateParser.template.get("sequences");
if (sequences != null) {
sequences.forEach(seqObj -> {
var seqJson = (JSONObject) seqObj;
String name = seqJson.get(Sequence.NAME).toString();
int seq = ((Long) seqJson.get(Sequence.SEQ)).intValue();
sequenceFacade.getNextSequenceNumber(name);
Optional<Sequence> foundSeq = sequenceFacade.getAllSequences().stream().filter(s -> s.getName().equals(name)).findFirst();
if (foundSeq.isPresent()) {
var sequence = new Sequence(name, seq);
sequence.setId(foundSeq.get().getId());
sequenceFacade.updateSequence(foundSeq.get().getId(), sequence);
}
});
}
}
use of io.lumeer.api.model.Sequence in project engine by Lumeer.
the class PusherFacade method removeSequenceNotification.
public void removeSequenceNotification(@Observes final RemoveSequence removeSequence) {
if (isEnabled()) {
try {
Sequence sequence = removeSequence.getSequence();
Set<String> userIds = permissionAdapter.getProjectUsersByRole(getOrganization(), getProject(), RoleType.TechConfig);
ResourceId message = new ResourceId(getAppId(), sequence.getId());
sendNotificationsByUsers(message, userIds, REMOVE_EVENT_SUFFIX);
} catch (Exception e) {
log.log(Level.WARNING, "Unable to send push notification: ", e);
}
}
}
Aggregations