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);
}
}
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);
}
}
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;
}
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;
}
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;
}
Aggregations