switch (type) { case "application": return deserializeApplicationId(id); case "program": return deserializeProgramId(id); case "flow": return deserializeFlowId(id); case "flowlet": return deserializeFlowletId(id); case "service": return deserializeServiceId(id); case "schedule": return deserializeSchedule(id); case "worker": return deserializeWorkerId(id); case "workflow": return deserializeWorkflowId(id); case "datasetinstance": return deserializeDatasetInstanceId(id); case "stream": return deserializeStreamId(id); case "view": return deserializeViewId(id); case "artifact": return deserializeArtifactId(id); default: throw new UnsupportedOperationException(
private DatasetId deserializeDatasetInstanceId(JsonObject id) { NamespaceId namespace = deserializeNamespace(id); String instanceId = id.get("instanceId").getAsString(); return new DatasetId(namespace.getNamespace(), instanceId); }
private FlowId deserializeFlowId(JsonObject id) { ProgramId flow = deserializeProgramId(id); return new FlowId(flow.getParent(), id.get("flow").getAsString()); }
private ProgramId deserializeProgramId(JsonObject id) { ApplicationId app = deserializeApplicationId(id.getAsJsonObject("application")); ProgramType programType = ProgramType.valueOf(id.get("type").getAsString().toUpperCase()); String programId = id.get("id").getAsString(); return new ProgramId(app.getNamespace(), app.getApplication(), programType, programId); }
private StreamViewId deserializeViewId(JsonObject id) { StreamId streamId = deserializeStreamId(id.getAsJsonObject("stream")); String view = id.get("id").getAsString(); return new StreamViewId(streamId.getNamespace(), streamId.getStream(), view); } }
private FlowletId deserializeFlowletId(JsonObject id) { FlowId flow = deserializeFlowId(id.getAsJsonObject("flow")); String flowletId = id.get("id").getAsString(); return new FlowletId(flow.getParent(), flow.getProgram(), flowletId); }
private WorkerId deserializeWorkerId(JsonObject id) { ProgramId program = deserializeProgramId(id); return new WorkerId(program.getParent(), program.getProgram()); }
private ScheduleId deserializeSchedule(JsonObject id) { ApplicationId app = deserializeApplicationId(id.getAsJsonObject("application")); String scheduleId = id.get("id").getAsString(); return new ScheduleId(app.getNamespace(), app.getApplication(), app.getVersion(), scheduleId); }
private ApplicationId deserializeApplicationId(JsonObject id) { NamespaceId namespace = deserializeNamespace(id); String applicationId = id.get("applicationId").getAsString(); return new ApplicationId(namespace.getNamespace(), applicationId); }
private ServiceId deserializeServiceId(JsonObject id) { ProgramId program = deserializeProgramId(id); return new ServiceId(program.getParent(), program.getProgram()); }
private StreamId deserializeStreamId(JsonObject id) { NamespaceId namespace = deserializeNamespace(id); String streamName = id.get("streamName").getAsString(); return new StreamId(namespace.getNamespace(), streamName); }
private WorkflowId deserializeWorkflowId(JsonObject id) { ProgramId program = deserializeProgramId(id); return new WorkflowId(program.getParent(), program.getProgram()); }
private ArtifactId deserializeArtifactId(JsonObject id) { NamespaceId namespace = deserializeNamespace(id); String artifactName = id.get("name").getAsString(); ArtifactVersion artifactVersion = new ArtifactVersion(id.get("version").getAsJsonObject() .get("version").getAsString()); return new ArtifactId(namespace.getNamespace(), artifactName, artifactVersion.getVersion()); }