无法在isis rest webservice的响应中看到对象内可用的变量

时间:2018-06-06 09:12:33

标签: isis

我有一个班级区域

  package domainapp.dom.zone;

import domainapp.dom.constants.ModelConstants;
import domainapp.dom.datasource.DataSource;
import domainapp.dom.datasource.DataSourceMenu;
import domainapp.dom.ehr.EHR;
import domainapp.dom.ehr.EHRMenu;
import domainapp.dom.field.*;
import domainapp.dom.mappings.EditorsSectionMapping;
import domainapp.dom.mappings.EditorsSectionMappingRepository;
import domainapp.dom.mappings.ZoneWorkTypeSectionMappingRepository;
import domainapp.dom.util.DomainObjectUtils;
import domainapp.dom.zonecompliance.ZoneCompliance;
import domainapp.dom.zonecompliance.ZoneComplianceMenu;
import domainapp.dom.zonetype.ZoneType;
import domainapp.dom.zonetype.ZoneTypeMenu;
import org.apache.isis.applib.annotation.*;
import org.apache.isis.applib.services.jdosupport.IsisJdoSupport;
import org.apache.isis.applib.services.message.MessageService;
import org.apache.isis.applib.services.repository.RepositoryService;
import org.apache.isis.applib.services.title.TitleService;
import org.apache.isis.applib.value.Blob;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonProperty;

import javax.inject.Inject;
import javax.jdo.PersistenceManager;
import javax.jdo.annotations.*;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;

@DomainObject(
        objectType = "zone.Zone",
        auditing = Auditing.ENABLED,
        publishing = Publishing.ENABLED
)

public class Zone implements Comparable<Zone>{

    @Column(allowsNull = "false", length = 256)
    @PrimaryKey
    @JsonProperty("id")
    protected String id;

    @Column(allowsNull = "true")
    @Property( hidden = Where.EVERYWHERE)
    @JsonIgnore
    protected Long zid;

    @Column(allowsNull = "true", length = 60)
    protected String name;

    @Column(allowsNull = "true")
    protected String description;

    @Column(allowsNull = "true")
    protected Long inferenceFamily;

    @Column(allowsNull = "true")
    @Element(dependent = "true",deleteAction = ForeignKeyAction.CASCADE,
            updateAction = ForeignKeyAction.CASCADE)
    protected EHR ehr;

    @Column(allowsNull = "true")
    protected ZoneType zoneType;

    @Column(allowsNull = "true")
    protected ZoneCompliance zoneCompliance;

    @Persistent(defaultFetchGroup="false", columns = {
            @Column(name = "someImage_name"),
            @Column(name = "someImage_mimetype"),
            @Column(name = "someImage_bytes", jdbcType = "BLOB", sqlType = "LONGVARBINARY")
    })
    @Column(allowsNull = "true")
    private Blob image;

    @Persistent(defaultFetchGroup="false", columns = {
            @Column(name = "cropped_image_name"),
            @Column(name = "cropped_image_mimetype"),
            @Column(name = "cropped_image_bytes", jdbcType = "BLOB", sqlType = "LONGVARBINARY")
    })
    @Column(allowsNull = "true")
    private Blob croppedImage;

    @Column(allowsNull = "true")
    private Integer areaId = 0;

    @Column(allowsNull = "true")
    private Float x = 0f;

    @Column(allowsNull = "true")
    private Float y = 0.f;

    @Column(allowsNull = "true")
    private Float z = 0.f;

    @Column(allowsNull = "true")
    private Float height = 0f;

    @Column(allowsNull = "true")
    private Float width = 0f;

    @Column(allowsNull = "true")
    private String croppedImageName;

    @Column(allowsNull = "true")
    private String input;

    @Column(allowsNull = "true")
    private String cssClass;



    @Join
    @Element(dependent = "true")
    @Column(allowsNull = "false")
    @Collection()
    protected List<DataSource> dataSources = new ArrayList<DataSource>();


    @Join
    @Element(dependent = "false")
    protected Set<Zone> childs =new LinkedHashSet<>();

    @Join
    @Element(dependent = "true")

    protected Set<Field> mappedFields = new LinkedHashSet<Field>();


    public Zone() {
    }

    public Zone(String name, String description, Long inferenceFamily, EHR ehr, ZoneType zoneType,
                ZoneCompliance zoneCompliance, Blob image, Blob croppedImage, Integer areaId, Float x,
                Float y, Float z, Float height, Float width, String croppedImageName, String input,
                String cssClass) {
        this.name = name;
        this.description = description;
        this.inferenceFamily = inferenceFamily;
        this.ehr = ehr;
        this.zoneType = zoneType;
        this.zoneCompliance = zoneCompliance;
        this.image = image;
        this.croppedImage = croppedImage;
        this.areaId = areaId;
        this.x = x;
        this.y = y;
        this.z = z;
        this.height = height;
        this.width = width;
        this.croppedImageName = croppedImageName;
        this.input = input;
        this.cssClass = cssClass;
    }

    public Zone(Zone zone) {
        this.setChilds(zone.getChilds());
        this.setDataSources(zone.getDataSources());
        this.setDescription(zone.getDescription());
        this.setEhr(zone.getEhr());
        this.setId(zone.getId());
        this.setMappedFields(zone.getMappedFields());
        this.setName(zone.getName());
        this.setZoneCompliance(zone.getZoneCompliance());
        this.setZoneType(zone.getZoneType());
        this.setImage(zone.getImage());
        this.setCroppedImage(zone.getCroppedImage());
        this.setInferenceFamily(zone.getInferenceFamily());
        this.setAreaId(zone.getAreaId());
        this.setX(zone.getX());
        this.setY(zone.getY());
        this.setZ(zone.getZ());
        this.setHeight(zone.getHeight());
        this.setWidth(zone.getWidth());
        this.setCroppedImageName(zone.getCroppedImageName());
        this.setInput(zone.getInput());
        this.setCssClass(zone.getCssClass());
    }



    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
 public Zone update(
            @ParameterLayout(named = "Name")
            @Parameter(optionality=Optionality.OPTIONAL)
            final String name,
            @ParameterLayout(named = "Description")
            @Parameter(optionality=Optionality.OPTIONAL)
            final String description,
            @ParameterLayout(named = "Zone Type")
            @Parameter(optionality=Optionality.OPTIONAL)
            final ZoneType zoneType,
            @ParameterLayout(named = "Zone Compliance")
            @Parameter(optionality=Optionality.OPTIONAL)
            final ZoneCompliance zoneCompliance,
            @ParameterLayout(named = "EHR Id")
            @Parameter(optionality=Optionality.OPTIONAL)
            final EHR ehr,
            @ParameterLayout(named = "Image")
            @Parameter(optionality=Optionality.OPTIONAL)
            final Blob image,
            @ParameterLayout(named = "Cropped Image")
            @Parameter(optionality=Optionality.OPTIONAL)
            final Blob croppedImage,
            @ParameterLayout(named = "Inference Family")
            @Parameter(optionality=Optionality.OPTIONAL)
            final Long inferenceFamily,
            @ParameterLayout(named = "AreaId")
            @Parameter(optionality=Optionality.OPTIONAL)
            final Integer areaId,
            @ParameterLayout(named = "x")
            @Parameter(optionality=Optionality.OPTIONAL)
            final Float x,
            @ParameterLayout(named = "y")
            @Parameter(optionality=Optionality.OPTIONAL)
            final Float y,
            @ParameterLayout(named = "z")
            @Parameter(optionality=Optionality.OPTIONAL)
            final Float z,
            @ParameterLayout(named = "height")
            @Parameter(optionality=Optionality.OPTIONAL)
            final Float height,
            @ParameterLayout(named = "width")
            @Parameter(optionality=Optionality.OPTIONAL)
            final Float width,
            @ParameterLayout(named = "croppedImageName")
            @Parameter(optionality=Optionality.OPTIONAL)
            final String croppedImageName,
            @ParameterLayout(named = "input")
            @Parameter(optionality=Optionality.OPTIONAL)
            final String input,
            @ParameterLayout(named = "cssClass")
            @Parameter(optionality=Optionality.OPTIONAL)
            final String cssClass){
        try{
            final String titleOf = titleService.titleOf(this);
            Zone newObject = new Zone();
            newObject.setName(name);
            newObject.setDescription(description);
            newObject.setZoneType(zoneType);
            newObject.setZoneCompliance(zoneCompliance);
            newObject.setEhr(ehr);
            newObject.setImage(image);
            newObject.setCroppedImage(croppedImage);
            newObject.setInferenceFamily(inferenceFamily);
            newObject.setDataSources(this.getDataSources());
            newObject.setAreaId(areaId);
            newObject.setX(x);
            newObject.setY(y);
            newObject.setZ(z);
            newObject.setHeight(height);
            newObject.setWidth(width);
            newObject.setCroppedImageName(croppedImageName);
            newObject.setCssClass(cssClass);
            newObject.setInput(input);
            if (ehr != null && this.ehr != ehr){
                this.ehr.getZones().remove(this);
                ehr.getZones().add(this);
            }
            DomainObjectUtils.validateFields(this,newObject);
            messageService.informUser(String.format("Zone updated successfully"));
        }
        catch (Exception e){
            messageService.raiseError(String.format("Updating zone failed!.."));
        }
        return this;
    }


    @Action()
    @ActionLayout(named = "Remove Field",position = ActionLayout.Position.PANEL)
    @MemberOrder(name = "mappedFields",sequence = "2")
    public Zone removeField(
            @ParameterLayout(named="Field") final Field field){
        try{
            this.getMappedFields().remove(field);
            field.delete();
            messageService.informUser(String.format("Field successfully removed"));
        }
        catch (Exception e){
            messageService.raiseError(String.format("Removing field failed!.."));
        }
        return this;
    }


    @Action()
    @ActionLayout(named = "Add Condition",position = ActionLayout.Position.PANEL)
    @MemberOrder(name = "mappedFields",sequence = "4")
    public Zone addCondition(
            @ParameterLayout(named="Option")
            final String option,
            @ParameterLayout(named="OptionId")
            final int optionId,
            @ParameterLayout(named="Condition")
            final String condition,
            @ParameterLayout(named="Value")
            @Parameter(optionality=Optionality.OPTIONAL)
            final String value,
            @ParameterLayout(named="Formula")
            @Parameter(optionality=Optionality.OPTIONAL)
            final String formula,
            @ParameterLayout(named="InputValueType")
            @Parameter(optionality=Optionality.OPTIONAL)
            final InputValueType valueType,
            @ParameterLayout(named="WorkType")
            @Parameter(optionality=Optionality.OPTIONAL)
            final String workType,
            @ParameterLayout(named="Section")
            @Parameter(optionality=Optionality.OPTIONAL)
            final String section){
        try{
            Field field = fieldRepository.addCondition(option,optionId,value, formula, this, condition, valueType, workType, section);
            if (field != null){
                this.getMappedFields().add(field);
                messageService.informUser(String.format("New condition added successfully added"));
            }
            else {
                messageService.raiseError(String.format("Adding condition failed!.."));
            }
        }
        catch (Exception e){
            messageService.raiseError(String.format("Adding condition failed!.."));
        }
        return this;
    }

    @Action(semantics = SemanticsOf.NON_IDEMPOTENT)
    public List<Field> zoneConditionList(){
        return fieldRepository.getZoneConditions(this);
    }


    @Action
    public Zone deleteImage(){
        this.setImage(null);
        return this;
    }

    @Action
    public Zone deleteCroppedImage(){
        this.setCroppedImage(null);
        return this;
    }



    @Action()
    public List<EditorsSectionMapping> findEditorSectionMappings(){
        return editorsSectionMappingRepository.findByZone(this);
    }

    @Programmatic
    public List<DataSource> autoComplete0RemoveDataSource() {
        return this.getDataSources();
    }

    @Programmatic
    public List<ZoneType> autoComplete2AddChild(String zoneType) {
        return zoneTypeMenu.findByName(zoneType);
    }

    @Programmatic
    public List<EHR> autoComplete0MoveZone(String ehrName) {
        return ehrMenu.listAll();
    }

    @Programmatic
    public List<Zone> autoComplete1MoveZone(String zoneName) {
        return zoneMenu.listAll();
    }

    @Programmatic
    public List<EHR> autoComplete3AddChild(String ehrName) {
        return ehrMenu.findByName(ehrName);
    }

    @Programmatic
    public List<ZoneCompliance> autoComplete4AddChild(String zoneCompliance) {
        return zoneComplianceMenu.findByName(zoneCompliance);
    }

    @Programmatic
    public Set<Zone> autoComplete0RemoveChild(String child) {
        return getChilds();
    }



    @Programmatic
    public Set<Field> autoComplete0RemoveField(String fieldName) {
        return this.getMappedFields();
    }

    @Programmatic
    public List<ZoneType> autoComplete2Update(String name) {
        return zoneTypeMenu.findByName(name);
    }

    @Programmatic
    public List<ZoneCompliance> autoComplete3Update(String name) {
        return zoneComplianceMenu.findByName(name);
    }

    @Programmatic
    public List<EHR> autoComplete4Update(String name) {
        return ehrMenu.findByName(name);
    }

    @Programmatic
    public List<EHR> autoCompleteEHR(String name) {
        return ehrMenu.findByName(name);
    }

    @Programmatic
    public List<ZoneType> autoCompleteZoneType(String name) {
        return zoneTypeMenu.findByName(name);
    }

    @Programmatic
    public List<ZoneCompliance> autoCompleteZoneCompliance(String name) {
        return zoneComplianceMenu.findByName(name);
    }

    @Programmatic
    public List<InputValueType> autoComplete5AddCondition(String type) {
        return inputValueTypeMenu.listAll();
    }

    public String title() {
        return titleService.titleOf(getName());
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public EHR getEhr() {
        return ehr;
    }

    public Long getZid() {
        return zid;
    }

    public void setZid(Long zid) {
        this.zid = zid;
    }

    @JsonIgnore
    public Blob getImage() {
        return image;
    }

    public void setImage(Blob image) {
        this.image = image;
    }

    @JsonIgnore
    public Blob getCroppedImage() {
        return croppedImage;
    }

    public void setCroppedImage(Blob croppedImage) {
        this.croppedImage = croppedImage;
    }

    public void setEhr(EHR ehr) {
        this.ehr = ehr;
    }

    public ZoneType getZoneType() {
        return zoneType;
    }

    public void setZoneType(ZoneType zoneType) {
        this.zoneType = zoneType;
    }

    public ZoneCompliance getZoneCompliance() {
        return zoneCompliance;
    }

    public void setZoneCompliance(ZoneCompliance zoneCompliance) {
        this.zoneCompliance = zoneCompliance;
    }

    public Set<Zone> getChilds() {
        return childs;
    }

    public void setChilds(Set<Zone> childs) {
        this.childs = childs;
    }

    public Set<Field> getMappedFields() {
        return mappedFields;
    }

    public void setMappedFields(Set<Field> mappedFields) {
        this.mappedFields = mappedFields;
    }

    public List<DataSource> getDataSources() {
        return dataSources;
    }

    public void setDataSources(List<DataSource> dataSources) {
        this.dataSources = dataSources;
    }


    public Integer getAreaId() {
        return areaId;
    }

    public void setAreaId(Integer areaId) {
        this.areaId = areaId;
    }

    public Float getX() {
        return x;
    }

    public void setX(Float x) {
        this.x = x;
    }

    public Float getY() {
        return y;
    }

    public void setY(Float y) {
        this.y = y;
    }

    public Float getZ() {
        return z;
    }

    public void setZ(Float z) {
        this.z = z;
    }

    public Float getHeight() {
        return height;
    }

    public void setHeight(Float height) {
        this.height = height;
    }

    public Float getWidth() {
        return width;
    }

    public void setWidth(Float width) {
        this.width = width;
    }

    public String getCroppedImageName() {
        return croppedImageName;
    }

    public void setCroppedImageName(String croppedImageName) {
        this.croppedImageName = croppedImageName;
    }

    public String getInput() {
        return input;
    }

    public void setInput(String input) {
        this.input = input;
    }

    public String getCssClass() {
        return cssClass;
    }

    public void setCssClass(String cssClass) {
        this.cssClass = cssClass;
    }

    public String getId() {
        return id;
    }
    @JsonProperty("id")
    public String getObjectId(){
        if (!id.toLowerCase().startsWith(ModelConstants.ID_PREFIX))
            return ModelConstants.ID_PREFIX+id;
        return id;
    }

    public Long getInferenceFamily() {
        return inferenceFamily;
    }

    public void setInferenceFamily(Long inferenceFamily) {
        this.inferenceFamily = inferenceFamily;
    }

    public void setId(String id) {
        this.id = id;
    }

    @Override
    public int compareTo(Zone zone) {
        return 0;
    }

    @JsonIgnore
    @Inject
    IsisJdoSupport isisJdoSupport;

    @JsonIgnore
    @javax.inject.Inject
    MessageService messageService;

    @JsonIgnore
    @javax.inject.Inject
    RepositoryService repositoryService;

    @Inject
    InputValueTypeMenu inputValueTypeMenu;

    @JsonIgnore
    @javax.inject.Inject
    TitleService titleService;

    @JsonIgnore
    @javax.inject.Inject
    EHRMenu ehrMenu;

    @JsonIgnore
    @javax.inject.Inject
    ZoneTypeMenu zoneTypeMenu;

    @JsonIgnore
    @javax.inject.Inject
    ZoneComplianceMenu zoneComplianceMenu;

    @JsonIgnore
    @Inject ZoneRepository zoneRepository;

    @JsonIgnore
    @Inject
    FieldRepository fieldRepository;

    @Inject
    EditorsSectionMappingRepository editorsSectionMappingRepository;

    @JsonIgnore
    @Inject
    ZoneWorkTypeSectionMappingRepository zoneWorkTypeSectionMappingRepository;

    @JsonIgnore
    @Inject
    DataSourceMenu dataSourceMenu;

    @JsonIgnore
    @Inject
    FieldMenu fieldMenu;

    @JsonIgnore
    @javax.inject.Inject
    ZoneMenu zoneMenu;



}

当我从Action()返回Zone时,它将区域对象转换为Json并向UI发送响应。区域中有一个字段mappedFields,它也应该出现在响应中。但由于某些原因,它没有出现在回复中。我对isis非常陌生,所以如果我遗漏了一些东西,我会道歉。如果您需要更多信息,请告诉我。我真的陷入了这个问题。提前致谢。干杯!

0 个答案:

没有答案