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

com.canoo.dolphin.server.impl.ServerControllerActionCallBean Maven / Gradle / Ivy

Go to download

The Dolphin Platform is a framework that implements the presentation model pattern and provides amodern way to create enterprise applications. The Platform provides several client implementations that all canbe used in combination with a general sever API.

There is a newer version: 1.0.0.CR5
Show newest version
package com.canoo.dolphin.server.impl;

import com.canoo.dolphin.impl.AbstractControllerActionCallBean;
import com.canoo.dolphin.impl.ClassRepositoryImpl;
import com.canoo.dolphin.impl.DolphinUtils;
import com.canoo.dolphin.internal.BeanRepository;
import org.opendolphin.core.Attribute;
import org.opendolphin.core.PresentationModel;
import org.opendolphin.core.Tag;

public class ServerControllerActionCallBean extends AbstractControllerActionCallBean {

    private final BeanRepository beanRepository;
    private final PresentationModel pm;

    public ServerControllerActionCallBean(BeanRepository beanRepository, PresentationModel pm) {
        this.beanRepository = beanRepository;
        this.pm = pm;
    }

    public String getControllerId() {
        return (String) pm.findAttributeByPropertyName(CONTROLLER_ID).getValue();
    }

    public String getActionName() {
        return (String) pm.findAttributeByPropertyName(ACTION_NAME).getValue();
    }

    public void setError(boolean error) {
        pm.findAttributeByPropertyName(ERROR_CODE).setValue(error);
    }

    public Object getParam(String name) {
        final String internalName = PARAM_PREFIX + name;
        final Attribute valueAttribute = pm.findAttributeByPropertyNameAndTag(internalName, Tag.VALUE);
        final Attribute typeAttribute = pm.findAttributeByPropertyNameAndTag(internalName, Tag.VALUE_TYPE);
        if (valueAttribute == null || typeAttribute == null) {
            throw new IllegalArgumentException(String.format("Invoking DolphinAction requires parameter '%s', but it was not send", name));
        }
        final ClassRepositoryImpl.FieldType fieldType = DolphinUtils.mapFieldTypeFromDolphin(typeAttribute.getValue());
        return beanRepository.mapDolphinToObject(valueAttribute.getValue(), fieldType);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy