use of org.motechproject.mds.domain.Entity in project motech by motech.
the class EntityServiceImpl method updateMaxFetchDepth.
@Override
@Transactional
public void updateMaxFetchDepth(Long entityId, Integer maxFetchDepth) {
Entity entity = allEntities.retrieveById(entityId);
assertEntityExists(entity, entityId);
entity.setMaxFetchDepth(maxFetchDepth);
allEntities.update(entity);
}
use of org.motechproject.mds.domain.Entity in project motech by motech.
the class EntityServiceImpl method getEntityFieldById.
@Override
@Transactional
public FieldDto getEntityFieldById(Long entityId, Long fieldId) {
Entity entity = allEntities.retrieveById(entityId);
Field field = entity.getField(fieldId);
if (field == null) {
throw new FieldNotFoundException(entity.getClassName(), fieldId);
}
return field.toDto();
}
use of org.motechproject.mds.domain.Entity in project motech by motech.
the class EntityServiceImpl method updateTracking.
@Override
@Transactional
public void updateTracking(Long entityId, TrackingDto trackingDto) {
Entity entity = allEntities.retrieveById(entityId);
assertEntityExists(entity, entityId);
entity.updateTracking(trackingDto);
}
use of org.motechproject.mds.domain.Entity in project motech by motech.
the class EntityServiceImpl method updateDraft.
@Override
@Transactional
public EntityDto updateDraft(Long entityId) {
Entity entity = allEntities.retrieveById(entityId);
EntityDraft draft = getEntityDraft(entityId);
allEntityDrafts.setProperties(draft, entity);
draft.setChangesMade(false);
return draft.toDto();
}
use of org.motechproject.mds.domain.Entity in project motech by motech.
the class SwaggerGeneratorTest method entities.
private List<Entity> entities() {
List<Entity> entities = new ArrayList<>();
// Entity 1
Entity entity = new Entity();
entity.setClassName("org.example.TestEntity");
entity.setName("TestEntity");
entity.setModule("example");
entity.setNamespace("ns");
RestOptions restOptions = new RestOptions(entity);
restOptions.setAllowCreate(true);
restOptions.setAllowRead(true);
entity.setRestOptions(restOptions);
List<Field> fields = new ArrayList<>();
Field strField = field("str", String.class, true, true);
strField.setTooltip("A string field used in tests");
fields.add(strField);
fields.add(field("integerField", Integer.class, true, true));
Field longField = field("longField", Long.class, false, true);
fields.add(longField);
fields.add(field("timeField", Time.class, false, true));
fields.add(field("ignoredField", String.class, false, false));
fields.addAll(autoGeneratedFields());
entity.setFields(fields);
Lookup lookup = new Lookup("Find By Str & Long", true, true, asList(strField, longField), true, "findByStrLong");
lookup.setFieldsOrder(asList("str", "longField"));
entity.addLookup(lookup);
entities.add(entity);
// Entity 2
entity = new Entity();
entity.setClassName("org.motechproject.ExampleEnt");
entity.setName("ExampleEnt");
restOptions = new RestOptions(entity);
restOptions.setAllowUpdate(true);
restOptions.setAllowDelete(true);
entity.setRestOptions(restOptions);
fields = new ArrayList<>();
fields.add(field("doubleField", Double.class, true, true));
fields.add(field("dateField", Date.class, false, true));
Field dtField = field("dtField", DateTime.class, false, true);
fields.add(dtField);
fields.add(field("ldField", LocalDate.class, false, true));
Field localeField = field("localeField", Locale.class, false, true);
fields.add(localeField);
Field listField = FieldTestHelper.fieldWithComboboxSettings(entity, "listField", "list disp", List.class, true, false, asList("one", "two", "three"));
listField.setExposedViaRest(true);
listField.setRequired(true);
fields.add(listField);
fields.addAll(autoGeneratedFields());
entity.setFields(fields);
lookup = new Lookup("By Dt and Locale", false, true, asList(dtField, localeField), false, "byDtAndLocale");
lookup.setRangeLookupFields(asList(dtField.getName()));
lookup.setSetLookupFields(asList(localeField.getName()));
lookup.setFieldsOrder(asList("dtField", "localeField"));
entity.addLookup(lookup);
entities.add(entity);
return entities;
}
Aggregations