• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

temporalio / sdk-java / #175

pending completion
#175

push

github-actions

web-flow
Worker / Build Id versioning (#1786)

Implement new worker build id based versioning feature

236 of 236 new or added lines in 24 files covered. (100.0%)

18343 of 23697 relevant lines covered (77.41%)

0.81 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/temporal-sdk/src/main/java/io/temporal/client/WorkflowExecutionMetadata.java
1
/*
2
 * Copyright (C) 2022 Temporal Technologies, Inc. All Rights Reserved.
3
 *
4
 * Copyright (C) 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
5
 *
6
 * Modifications copyright (C) 2017 Uber Technologies, Inc.
7
 *
8
 * Licensed under the Apache License, Version 2.0 (the "License");
9
 * you may not use this material except in compliance with the License.
10
 * You may obtain a copy of the License at
11
 *
12
 *   http://www.apache.org/licenses/LICENSE-2.0
13
 *
14
 * Unless required by applicable law or agreed to in writing, software
15
 * distributed under the License is distributed on an "AS IS" BASIS,
16
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
 * See the License for the specific language governing permissions and
18
 * limitations under the License.
19
 */
20

21
package io.temporal.client;
22

23
import com.google.common.base.Preconditions;
24
import io.temporal.api.common.v1.Payload;
25
import io.temporal.api.common.v1.WorkflowExecution;
26
import io.temporal.api.enums.v1.WorkflowExecutionStatus;
27
import io.temporal.api.workflow.v1.WorkflowExecutionInfo;
28
import io.temporal.common.SearchAttributes;
29
import io.temporal.common.converter.DataConverter;
30
import io.temporal.internal.common.ProtobufTimeUtils;
31
import io.temporal.internal.common.SearchAttributesUtil;
32
import java.lang.reflect.Type;
33
import java.time.Instant;
34
import java.util.Collections;
35
import java.util.List;
36
import java.util.Map;
37
import java.util.Objects;
38
import javax.annotation.Nonnull;
39
import javax.annotation.Nullable;
40

41
public class WorkflowExecutionMetadata {
42
  private final @Nonnull WorkflowExecutionInfo info;
43
  private final @Nonnull DataConverter dataConverter;
44

45
  WorkflowExecutionMetadata(
46
      @Nonnull WorkflowExecutionInfo info, @Nonnull DataConverter dataConverter) {
×
47
    this.info = Preconditions.checkNotNull(info, "info");
×
48
    this.dataConverter = Preconditions.checkNotNull(dataConverter, "dataConverter");
×
49
  }
×
50

51
  @Nonnull
52
  public WorkflowExecution getExecution() {
53
    return info.getExecution();
×
54
  }
55

56
  @Nonnull
57
  public String getWorkflowType() {
58
    return info.getType().getName();
×
59
  }
60

61
  @Nonnull
62
  public String getTaskQueue() {
63
    return info.getTaskQueue();
×
64
  }
65

66
  @Nonnull
67
  public Instant getStartTime() {
68
    return ProtobufTimeUtils.toJavaInstant(info.getStartTime());
×
69
  }
70

71
  @Nonnull
72
  public Instant getExecutionTime() {
73
    return ProtobufTimeUtils.toJavaInstant(info.getExecutionTime());
×
74
  }
75

76
  @Nullable
77
  public Instant getCloseTime() {
78
    return info.hasCloseTime() ? ProtobufTimeUtils.toJavaInstant(info.getCloseTime()) : null;
×
79
  }
80

81
  @Nonnull
82
  public WorkflowExecutionStatus getStatus() {
83
    return info.getStatus();
×
84
  }
85

86
  public long getHistoryLength() {
87
    return info.getHistoryLength();
×
88
  }
89

90
  @Nullable
91
  public String getParentNamespace() {
92
    return info.hasParentExecution() ? info.getParentNamespaceId() : null;
×
93
  }
94

95
  @Nullable
96
  public WorkflowExecution getParentExecution() {
97
    return info.hasParentExecution() ? info.getParentExecution() : null;
×
98
  }
99

100
  /**
101
   * @deprecated use {@link #getTypedSearchAttributes} instead.
102
   */
103
  @Deprecated
104
  @Nonnull
105
  public Map<String, List<?>> getSearchAttributes() {
106
    return Collections.unmodifiableMap(SearchAttributesUtil.decode(info.getSearchAttributes()));
×
107
  }
108

109
  /** Get search attributes as a typed set. */
110
  @Nonnull
111
  public SearchAttributes getTypedSearchAttributes() {
112
    return SearchAttributesUtil.decodeTyped(info.getSearchAttributes());
×
113
  }
114

115
  @Nullable
116
  public <T> Object getMemo(String key, Class<T> valueClass) {
117
    return getMemo(key, valueClass, valueClass);
×
118
  }
119

120
  @Nullable
121
  public <T> T getMemo(String key, Class<T> valueClass, Type genericType) {
122
    Payload memo = info.getMemo().getFieldsMap().get(key);
×
123
    if (memo == null) {
×
124
      return null;
×
125
    }
126
    return dataConverter.fromPayload(memo, valueClass, genericType);
×
127
  }
128

129
  @Nonnull
130
  public WorkflowExecutionInfo getWorkflowExecutionInfo() {
131
    return info;
×
132
  }
133

134
  @Override
135
  public boolean equals(Object o) {
136
    if (this == o) return true;
×
137
    if (o == null || getClass() != o.getClass()) return false;
×
138
    WorkflowExecutionMetadata that = (WorkflowExecutionMetadata) o;
×
139
    return info.equals(that.info);
×
140
  }
141

142
  @Override
143
  public int hashCode() {
144
    return Objects.hash(info);
×
145
  }
146
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc