Search in sources :

Example 1 with AttributeType

use of org.openforis.collect.designer.metamodel.AttributeType in project collect by openforis.

the class AttributeConversionVM method convert.

@Command
public void convert(@ContextParam(ContextType.BIND_CONTEXT) BindContext ctx) {
    if (validateForm(ctx)) {
        String typeLabel = form.get("type");
        AttributeType type = AttributeType.fromLabel(typeLabel);
        AttributeDefinition convertedAttribute = new AttributeConverter().convert(attributeDefinition, type);
        dispatchNodeConvertedCommand(convertedAttribute);
        Window popUp = ComponentUtil.getClosest(ctx.getComponent(), Window.class);
        closePopUp(popUp);
    }
}
Also used : Window(org.zkoss.zul.Window) AttributeType(org.openforis.collect.designer.metamodel.AttributeType) AttributeDefinition(org.openforis.idm.metamodel.AttributeDefinition) Command(org.zkoss.bind.annotation.Command)

Example 2 with AttributeType

use of org.openforis.collect.designer.metamodel.AttributeType in project collect by openforis.

the class SchemaVM method refreshNodeForm.

protected void refreshNodeForm() {
    nodeFormInclude.setSrc(null);
    if (editedNode != null) {
        nodeFormInclude.setDynamicProperty("parentEntity", editedNodeParentEntity);
        nodeFormInclude.setDynamicProperty("item", editedNode);
        nodeFormInclude.setDynamicProperty("newItem", newNode);
        String nodeNameTextboxPath;
        String location;
        if (editedNode instanceof UITab) {
            location = Resources.Component.TAB.getLocation();
            nodeNameTextboxPath = TAB_NAME_LABEL_PATH;
        } else if (editedNode instanceof EntityDefinition) {
            location = Resources.Component.ENTITY.getLocation();
            nodeNameTextboxPath = ENTITY_NAME_TEXTBOX_PATH;
        } else {
            AttributeType attributeType = AttributeType.valueOf((AttributeDefinition) editedNode);
            String locationFormat = Resources.Component.ATTRIBUTE.getLocation();
            String attributeTypeShort = attributeType.name().toLowerCase(Locale.ENGLISH);
            location = MessageFormat.format(locationFormat, attributeTypeShort);
            nodeNameTextboxPath = ATTRIBUTE_NAME_TEXTBOX_PATH;
        }
        nodeFormInclude.setSrc(location);
        // set focus on name textbox
        Textbox nodeNameTextbox = (Textbox) Path.getComponent(nodeFormInclude.getSpaceOwner(), nodeNameTextboxPath);
        nodeNameTextbox.setFocus(true);
    }
}
Also used : UITab(org.openforis.collect.metamodel.ui.UITab) EntityDefinition(org.openforis.idm.metamodel.EntityDefinition) AttributeType(org.openforis.collect.designer.metamodel.AttributeType) Textbox(org.zkoss.zul.Textbox) KeyAttributeDefinition(org.openforis.idm.metamodel.KeyAttributeDefinition) AttributeDefinition(org.openforis.idm.metamodel.AttributeDefinition)

Example 3 with AttributeType

use of org.openforis.collect.designer.metamodel.AttributeType in project collect by openforis.

the class SchemaVM method getAttributeIcon.

public static String getAttributeIcon(String type) {
    AttributeType attributeType = AttributeType.valueOf(type);
    String result = NODE_TYPES_IMAGES_PATH + attributeType.name().toLowerCase(Locale.ENGLISH) + "-small.png";
    return result;
}
Also used : AttributeType(org.openforis.collect.designer.metamodel.AttributeType)

Example 4 with AttributeType

use of org.openforis.collect.designer.metamodel.AttributeType in project collect by openforis.

the class SchemaVM method getAttributeTypeValues.

public List<String> getAttributeTypeValues() {
    if (survey == null) {
        // TODO session expired
        return Collections.emptyList();
    }
    List<String> result = new ArrayList<String>();
    AttributeType[] values = AttributeType.values();
    for (AttributeType type : values) {
        if (isSupported(type)) {
            result.add(type.name());
        }
    }
    return result;
}
Also used : AttributeType(org.openforis.collect.designer.metamodel.AttributeType) ArrayList(java.util.ArrayList)

Example 5 with AttributeType

use of org.openforis.collect.designer.metamodel.AttributeType in project collect by openforis.

the class CollectEarthSurveyValidator method validateAllRequiredFieldsDefined.

private List<SurveyValidationResult> validateAllRequiredFieldsDefined(CollectSurvey survey) {
    final List<SurveyValidationResult> results = new ArrayList<SurveyValidationResult>();
    final EntityDefinition rootEntityDef = getMainRootEntityDefinition(survey);
    for (CollectEarthField field : REQUIRED_FIELDS) {
        String fieldName = field.getName();
        try {
            NodeDefinition foundFieldDef = rootEntityDef.getChildDefinition(fieldName);
            if (!field.getType().isAssignableFrom(foundFieldDef.getClass())) {
                Class<? extends AttributeDefinition> type = field.getType();
                AttributeType expectedAttributeType = AttributeType.valueOf(type);
                String expectedType = expectedAttributeType.getLabel();
                String foundType;
                if (foundFieldDef instanceof AttributeDefinition) {
                    AttributeType foundTypeEnum = AttributeType.valueOf((AttributeDefinition) foundFieldDef);
                    foundType = foundTypeEnum.getLabel();
                } else {
                    foundType = NodeType.ENTITY.getLabel();
                }
                results.add(new SurveyValidationResult(rootEntityDef.getPath() + "/" + fieldName, "survey.validation.collect_earth.unexpected_field_type", expectedType, foundType));
            }
        } catch (Exception e) {
            results.add(new SurveyValidationResult(rootEntityDef.getPath() + "/" + fieldName, "survey.validation.collect_earth.missing_required_field"));
        }
    }
    return results;
}
Also used : EntityDefinition(org.openforis.idm.metamodel.EntityDefinition) AttributeType(org.openforis.collect.designer.metamodel.AttributeType) ArrayList(java.util.ArrayList) NodeDefinition(org.openforis.idm.metamodel.NodeDefinition) CoordinateAttributeDefinition(org.openforis.idm.metamodel.CoordinateAttributeDefinition) BooleanAttributeDefinition(org.openforis.idm.metamodel.BooleanAttributeDefinition) AttributeDefinition(org.openforis.idm.metamodel.AttributeDefinition) TextAttributeDefinition(org.openforis.idm.metamodel.TextAttributeDefinition) DateAttributeDefinition(org.openforis.idm.metamodel.DateAttributeDefinition)

Aggregations

AttributeType (org.openforis.collect.designer.metamodel.AttributeType)10 AttributeDefinition (org.openforis.idm.metamodel.AttributeDefinition)6 ArrayList (java.util.ArrayList)3 EntityDefinition (org.openforis.idm.metamodel.EntityDefinition)3 UITab (org.openforis.collect.metamodel.ui.UITab)2 KeyAttributeDefinition (org.openforis.idm.metamodel.KeyAttributeDefinition)2 BooleanAttributeDefinition (org.openforis.idm.metamodel.BooleanAttributeDefinition)1 CoordinateAttributeDefinition (org.openforis.idm.metamodel.CoordinateAttributeDefinition)1 DateAttributeDefinition (org.openforis.idm.metamodel.DateAttributeDefinition)1 NodeDefinition (org.openforis.idm.metamodel.NodeDefinition)1 SurveyObject (org.openforis.idm.metamodel.SurveyObject)1 TextAttributeDefinition (org.openforis.idm.metamodel.TextAttributeDefinition)1 Command (org.zkoss.bind.annotation.Command)1 Textbox (org.zkoss.zul.Textbox)1 Window (org.zkoss.zul.Window)1