001/** 002 * Copyright (C) 2006-2024 Talend Inc. - www.talend.com 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.talend.sdk.component.runtime.manager.chain; 017 018import org.talend.sdk.component.runtime.manager.chain.internal.DSLParser; 019import org.talend.sdk.component.runtime.manager.chain.internal.JobImpl; 020 021import lombok.Data; 022 023public interface Job { 024 025 static ComponentBuilder components() { 026 return new JobImpl.NodeBuilderImpl(); 027 } 028 029 interface ComponentBuilder { 030 031 NodeBuilder component(final String id, String uri); 032 } 033 034 interface NodeBuilder extends ComponentBuilder { 035 036 NodeBuilder property(String name, Object value); 037 038 FromBuilder connections(); 039 } 040 041 interface FromBuilder { 042 043 ToBuilder from(String id, String branch); 044 045 default ToBuilder from(String id) { 046 return from(id, "__default__"); 047 } 048 049 } 050 051 interface ToBuilder { 052 053 Builder to(String id, String branch); 054 055 default Builder to(String id) { 056 return to(id, "__default__"); 057 } 058 } 059 060 interface Builder extends FromBuilder { 061 062 ExecutorBuilder build(); 063 } 064 065 interface ExecutorBuilder { 066 067 ExecutorBuilder property(String name, Object value); 068 069 void run(); 070 } 071 072 @Data 073 class Component { 074 075 private final String id; 076 077 private boolean isSource = false; 078 079 private final DSLParser.Step node; 080 } 081 082 @Data 083 class Connection { 084 085 private final Component node; 086 087 private final String branch; 088 } 089 090 @Data 091 class Edge { 092 093 private final Connection from; 094 095 private final Connection to; 096 } 097 098}