package protobuf;

/**
 * Created by Peter Mösenthin.
 */
public class ProtobufLogicResolver {

    public static final String DEBUG_TAG = ProtobufLogicResolver.class.getSimpleName();

    public void resolve(RblProto.RBLMessage message){
        RblProto.RBLMessage.Logic logic = message.getLogic();

        switch (logic.getCrudType()){
            case CREATE:
                createLogic(logic);
                break;
            case RETRIEVE:
                retrieveLogic(logic);
                break;
            case UPDATE:
                updateLogic(logic);
                break;
            case DELETE:
                deleteLogic(logic);
                break;
        }
    }

    public void createLogic(RblProto.RBLMessage.Logic logic){

    }

    public void retrieveLogic(RblProto.RBLMessage.Logic logic){

    }

    public void updateLogic(RblProto.RBLMessage.Logic logic){

    }

    public void deleteLogic(RblProto.RBLMessage.Logic logic){

    }

}

@@ -12,16 +12,116 @@
 tobuf;%0A%0A
+import client.RaspberryLifeClient;%0Aimport data.model.Logic;%0Aimport system.service.DataBaseService;%0A%0A
 /**%0A * C
@@ -287,56 +287,155 @@
    p
-ublic void resolve(RblProto.RBLMessage message)%7B
+rivate RaspberryLifeClient client;%0A%0A    public void resolve(RaspberryLifeClient client, RblProto.RBLMessage message)%7B%0A        this.client = client;
 %0A   
@@ -943,32 +943,1532 @@
 e.Logic logic)%7B%0A
+        Logic logic_data = new Logic();%0A/*%0A        String initiators = %22%5B %22;%0A        for(RBLMessage.Actuator a : l.getInitiatorList())%7B%0A            initiators += a.getName() + %22(%22 + a.getActuatorId() + %22) %22;%0A        %7D%0A        initiators += %22%5D%22;%0A%0A        String receivers = %22%5B %22;%0A        for(RBLMessage.Actuator a : l.getReceiverList())%7B%0A            receivers += a.getName() + %22(%22 + a.getActuatorId() + %22) %22;%0A        %7D%0A        receivers += %22%5D%22;%0A%0A        String conditions = %22%5B %22;%0A        for(RBLMessage.Condition c : l.getConditionList())%7B%0A            conditions += %22FID=%22 + c.getFieldId()%0A                    + %22 TU=%22 + c.getThresholdUnder()%0A                    + %22 TO=%22 + c.getThresholdOver()%0A                    + %22 S=%22 + c.getState();%0A        %7D%0A        conditions += %22%5D%22;%0A%0A        String triggers = %22%5B %22;%0A        for(RBLMessage.Trigger t : l.getTriggerList())%7B%0A            triggers += %22IID=%22 + t.getInstructionId() + %22 %22%0A                        + %22 PARAMS=( %22;%0A            for(String s : t.getParametersList())%7B%0A                triggers += s + %22 %22;%0A            %7D%0A            triggers += %22)%22;%0A        %7D%0A        triggers += %22%5D%22;%0A%0A        Log.add(DEBUG_TAG,%0A                %22Received Logic:%22%0A                + %22 Name: %22 + l.getName()%0A                + %22 Initiators: %22 + initiators%0A                + %22 Conditions: %22 + conditions%0A                + %22 Receivers: %22 + receivers%0A                + %22 Triggers: %22 + triggers%0A        );%0A        */%0A%0A        DataBaseService.getInstance().writeLogic(logic_data);
 %0A    %7D%0A%0A    publ

move some logic parsing to resolver