Search in sources :

Example 16 with Lookup

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;
}
Also used : Field(org.motechproject.mds.domain.Field) Lookup(org.motechproject.mds.domain.Lookup)

Example 17 with Lookup

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);
}
Also used : Entity(org.motechproject.mds.domain.Entity) PersistenceManager(javax.jdo.PersistenceManager) Lookup(org.motechproject.mds.domain.Lookup) LinkedList(java.util.LinkedList) Before(org.junit.Before)

Example 18 with Lookup

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);
}
Also used : Entity(org.motechproject.mds.domain.Entity) Field(org.motechproject.mds.domain.Field) Lookup(org.motechproject.mds.domain.Lookup) Test(org.junit.Test)

Example 19 with Lookup

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");
}
Also used : Entity(org.motechproject.mds.domain.Entity) Field(org.motechproject.mds.domain.Field) Lookup(org.motechproject.mds.domain.Lookup) Test(org.junit.Test)

Example 20 with Lookup

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();
}
Also used : Lookup(org.motechproject.mds.domain.Lookup)

Aggregations

Lookup (org.motechproject.mds.domain.Lookup)30 Field (org.motechproject.mds.domain.Field)16 Entity (org.motechproject.mds.domain.Entity)12 ArrayList (java.util.ArrayList)8 Test (org.junit.Test)8 LookupDto (org.motechproject.mds.dto.LookupDto)5 HashSet (java.util.HashSet)4 MdsEntity (org.motechproject.mds.domain.MdsEntity)4 MdsVersionedEntity (org.motechproject.mds.domain.MdsVersionedEntity)4 HashMap (java.util.HashMap)3 FieldSetting (org.motechproject.mds.domain.FieldSetting)3 RestOptions (org.motechproject.mds.domain.RestOptions)3 Type (org.motechproject.mds.domain.Type)3 TypeSetting (org.motechproject.mds.domain.TypeSetting)3 LookupFieldDto (org.motechproject.mds.dto.LookupFieldDto)3 LinkedList (java.util.LinkedList)2 Query (javax.jdo.Query)2 Matchers.anyString (org.mockito.Matchers.anyString)2 Tracking (org.motechproject.mds.domain.Tracking)2 FieldDto (org.motechproject.mds.dto.FieldDto)2