All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.almworks.jira.structure.api.sync.SyncEvents Maven / Gradle / Ivy

There is a newer version: 17.25.3
Show newest version
package com.almworks.jira.structure.api.sync;

import com.almworks.jira.structure.api.util.La;
import com.almworks.jira.structure.api.util.StructureUtil;
import com.google.common.collect.ImmutableMap;
import org.jetbrains.annotations.NotNull;

import java.util.Map;

public class SyncEvents {
  public static final La> JIRA_EVENT_TO_MAP = new La>() {
    @Override
    public Map la(SyncEvent.Jira event) {
      if (event == null) return null;
      return buildSyncEventMap(event, 
        ImmutableMap.builder()
          .put("type", event.getEvent().getChangeType().toString())
          .put("issues", SyncAuditLogHelper.ISSUE_INFO.arrayList(event.getEvent().getAffectedIssuesSorted().toList()))
      );  
    }
  };
  
  public static final La> STRUCTURE_EVENT_TO_MAP = new La>() {
    @Override
    public Mapla(SyncEvent.Structure event) {
      if (event == null) return null;
      return buildSyncEventMap(event, 
        ImmutableMap.builder()
          .put("version", event.getHistoryEntry().getVersion()));
    }
  };

  @NotNull
  private static Map buildSyncEventMap(@NotNull SyncEvent event, ImmutableMap.Builder builder) {
    builder.put("timestamp", event.getTimestamp());
    builder.put("syncInstanceId", StructureUtil.nnl(event.getSyncInstanceId()));
    return builder.build();
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy