use of org.motechproject.mds.domain.Lookup in project motech by motech.
the class UserPreferencesServiceTest method getField1.
private Field getField1() {
Field field = new Field(null, "sampleField1", "Display Name 1", true, false, false, false, false, false, "default 1", "tooltip 1", "placeholder 1", new HashSet<Lookup>());
field.setUIDisplayable(true);
return field;
}
use of org.motechproject.mds.domain.Lookup in project motech by motech.
the class AllEntitiesContextIT method setUp.
@Before
public void setUp() throws Exception {
super.setUp();
PersistenceManager persistenceManager = getPersistenceManager();
persistenceManager.makePersistent(new Entity(SAMPLE_CLASS));
persistenceManager.makePersistent(new Entity(EXAMPLE_CLASS));
persistenceManager.makePersistent(new Entity(FOO_CLASS));
Entity entityWithLookups = new Entity(EXAMPLE_CLASS_WITH_LOOKUPS);
List<Lookup> lookups = new LinkedList<>();
lookups.add(new Lookup(EXAMPLE_LOOKUP_1, true, false, null, entityWithLookups));
lookups.add(new Lookup(EXAMPLE_LOOKUP_2, true, false, null, entityWithLookups));
entityWithLookups.setLookups(lookups);
persistenceManager.makePersistent(entityWithLookups);
}
use of org.motechproject.mds.domain.Lookup in project motech by motech.
the class FieldHelperTest method shouldAddMetadataForFields.
@Test
public void shouldAddMetadataForFields() {
Entity entity = new Entity("SampleEntity");
Field field = new Field(entity, "sampleField", "Display Name", true, false, false, false, false, "default", "tooltip", "placeholder", new HashSet<Lookup>());
FieldHelper.addMetadataForRelationship(TypeDto.MANY_TO_MANY_RELATIONSHIP.getTypeClass(), field);
assertEquals(field.getMetadata().size(), 4);
field.getMetadata().clear();
FieldHelper.addMetadataForRelationship(TypeDto.ONE_TO_MANY_RELATIONSHIP.getTypeClass(), field);
assertEquals(field.getMetadata().size(), 2);
field.getMetadata().clear();
FieldHelper.addMetadataForRelationship(TypeDto.ONE_TO_ONE_RELATIONSHIP.getTypeClass(), field);
assertEquals(field.getMetadata().size(), 1);
}
use of org.motechproject.mds.domain.Lookup in project motech by motech.
the class FieldHelperTest method shouldCreateAndSetMetadataForManyToManyRelationship.
@Test
public void shouldCreateAndSetMetadataForManyToManyRelationship() {
Entity entity = new Entity("SampleEntity");
Field field = new Field(entity, "sampleField", "Display Name", true, false, false, false, false, "default", "tooltip", "placeholder", new HashSet<Lookup>());
FieldHelper.createMetadataForManyToManyRelationship(field, "org.motechproject.sample.Test", "java.util.Set", "relatedField", true);
assertEquals(field.getMetadata().size(), 4);
assertEquals(field.getMetadataValue(Constants.MetadataKeys.OWNING_SIDE), "true");
assertEquals(field.getMetadataValue(Constants.MetadataKeys.RELATED_FIELD), "relatedField");
assertEquals(field.getMetadataValue(Constants.MetadataKeys.RELATED_CLASS), "org.motechproject.sample.Test");
assertEquals(field.getMetadataValue(Constants.MetadataKeys.RELATIONSHIP_COLLECTION_TYPE), "java.util.Set");
}
use of org.motechproject.mds.domain.Lookup in project motech by motech.
the class LookupWriter method writeLookupNamesArray.
public void writeLookupNamesArray(String name, List<Lookup> lookups) throws IOException {
jsonWriter.name(name);
jsonWriter.beginArray();
for (Lookup lookup : lookups) {
jsonWriter.value(lookup.getLookupName());
}
jsonWriter.endArray();
}
Aggregations