use of org.eclipse.scout.rt.platform.classid.ClassIdentifier in project scout.rt by eclipse.
the class MoveFormFieldTest method testMultiTemplateUsageFormMoveWithDeepLinkedTarget.
@Test
public void testMultiTemplateUsageFormMoveWithDeepLinkedTarget() throws Exception {
BEANS.get(IExtensionRegistry.class).registerMove(new ClassIdentifier(MainBoxStringField.class), 15d, new ClassIdentifier(SecondTemplateBox.class, TopFieldsBox.class));
MultiTemplateUsageForm form = new MultiTemplateUsageForm();
assertClasses(form.getMainBox().getFields(), FirstTemplateBox.class, SecondTemplateBox.class);
// first template box
FirstTemplateBox firstTemplateBox = form.getFirstTemplateBox();
assertClasses(firstTemplateBox.getFields(), TopFieldsBox.class, MiddleStringField.class, BottomFieldsBox.class);
assertClasses(firstTemplateBox.getTopFieldsBox().getFields(), TopStringField.class, BottomStringField.class);
assertClasses(firstTemplateBox.getBottomFieldsBox().getFields(), TopStringField.class, BottomStringField.class);
// second template box
SecondTemplateBox secondTemplateBox = form.getSecondTemplateBox();
assertClasses(secondTemplateBox.getFields(), TopFieldsBox.class, BottomFieldsBox.class);
assertClasses(secondTemplateBox.getTopFieldsBox().getFields(), TopStringField.class, MainBoxStringField.class, BottomStringField.class);
assertClasses(secondTemplateBox.getBottomFieldsBox().getFields(), TopStringField.class, BottomStringField.class);
}
use of org.eclipse.scout.rt.platform.classid.ClassIdentifier in project scout.rt by eclipse.
the class FormDataStatementBuilderTest method testTemplate1PropertyData_temlateValueDefinition.
@Test
public void testTemplate1PropertyData_temlateValueDefinition() {
m_builder.setBasicDefinition(new ClassIdentifier(FormData.Template1GroupBox.class, FormData.Template1GroupBox.TemplateProp.class), "TEMPLATE1_PROP", DataModelConstants.OPERATOR_EQ);
assertEquals(" AND TEMPLATE1_PROP=:__a1", m_builder.build(m_formData));
assertNotNull(m_builder.getBindMap());
assertEquals(1, m_builder.getBindMap().size());
assertEquals(TEMPLATE1_PROPERTY, m_builder.getBindMap().get("__a1"));
}
use of org.eclipse.scout.rt.platform.classid.ClassIdentifier in project scout.rt by eclipse.
the class BasicPartDefinition method createInstance.
/**
* Override this method to intercept and change part instance properties such as values, operation type, etc.<br>
* Sometimes it is convenient to set the operation to {@link DataModelConstants#OPERATOR_NONE} which uses the
* attribute itself as the complete statement part.
*
* @param builder
* @param formData
* the form data to be checked.
* @return the result EntityContribution. null if that part is to be ignored
* <p>
* normally calls
* {@link FormDataStatementBuilder#createSqlPart(Integer, String, int, List, List, boolean, Map)}
* <p>
* Can make use of alias markers such as @Person@.LAST_NAME, these are resolved in the
* {@link FormDataStatementBuilder}
* <p>
* Only additional bind values - other than the bindValues passed to createStatementPart - must be added using
* {@link FormDataStatementBuilder#addBind(String, Object)}
*/
public EntityContribution createInstance(FormDataStatementBuilder builder, AbstractFormData formData, Map<String, String> parentAliasMap) {
Map<Integer, Map<String, AbstractFormFieldData>> fieldsBreathFirstMap = formData.getAllFieldsRec();
Map<Integer, Map<String, AbstractPropertyData<?>>> propertiesBreathFirstMap = formData.getAllPropertiesRec();
ClassIdentifier[] valueTypes = getValueTypeClassIdentifiers();
/**
* the form data objects containing the runtime values {@link AbstractFormFieldData} and
* {@link AbstractPropertyData}
*/
ArrayList<Object> valueDatas = new ArrayList<Object>(valueTypes.length);
/**
* by default the names "a", "b", "c", ... represent the bindValues in the same order as the values
*/
ArrayList<String> bindNames = new ArrayList<String>(valueTypes.length);
/**
* the values of the {@link AbstractFormFieldData}s and {@link AbstractPropertyData}s in the same order
*/
ArrayList<Object> bindValues = new ArrayList<Object>(valueTypes.length);
for (int i = 0; i < valueTypes.length; i++) {
if (AbstractFormFieldData.class.isAssignableFrom(valueTypes[i].getLastSegment())) {
AbstractFormFieldData field = formData.findFieldByClass(fieldsBreathFirstMap, valueTypes[i]);
valueDatas.add(field);
bindNames.add("" + (char) (('a') + i));
if (field instanceof AbstractValueFieldData<?>) {
bindValues.add(((AbstractValueFieldData<?>) field).getValue());
} else {
bindValues.add(null);
}
} else if (AbstractPropertyData.class.isAssignableFrom(valueTypes[i].getLastSegment())) {
AbstractPropertyData<?> property = formData.findPropertyByClass(propertiesBreathFirstMap, valueTypes[i]);
valueDatas.add(property);
bindNames.add("" + (char) (('a') + i));
bindValues.add(property.getValue());
} else {
valueDatas.add(null);
bindNames.add("" + (char) (('a') + i));
bindValues.add(null);
}
}
//
String wherePart = createInstanceImpl(builder, valueDatas, bindNames, bindValues, parentAliasMap);
return EntityContribution.create(wherePart);
}
use of org.eclipse.scout.rt.platform.classid.ClassIdentifier in project scout.rt by eclipse.
the class ClassIdentifierTest method testConvertClassArray_nullClasses.
@Test
public void testConvertClassArray_nullClasses() {
ClassIdentifier[] cids = ClassIdentifier.convertClassArrayToClassIdentifierArray(String.class, null, Integer.class);
assertNotNull(cids);
assertEquals(2, cids.length);
assertArrayEquals(new ClassIdentifier[] { new ClassIdentifier(String.class), new ClassIdentifier(Integer.class) }, cids);
}
use of org.eclipse.scout.rt.platform.classid.ClassIdentifier in project scout.rt by eclipse.
the class ClassIdentifierTest method testCreateWithContextOnly.
@Test
public void testCreateWithContextOnly() {
ClassIdentifier cid = new ClassIdentifier(String.class);
ClassIdentifier cid2 = new ClassIdentifier(cid);
ClassIdentifier cid3 = new ClassIdentifier(cid, (Class[]) null);
assertNotSame(cid, cid2);
assertNotSame(cid, cid3);
assertEquals(cid, cid2);
assertEquals(cid, cid3);
assertArrayEquals(new Class[] { String.class }, cid2.getClasses());
assertArrayEquals(new Class[] { String.class }, cid3.getClasses());
}
Aggregations