-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathClassHelper.java
50 lines (38 loc) · 1.24 KB
/
ClassHelper.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package com.intuit.developer.sampleapp.crud.helper;
import java.util.List;
import org.apache.commons.lang.RandomStringUtils;
import com.intuit.ipp.data.Class;
import com.intuit.ipp.data.ReferenceType;
import com.intuit.ipp.exception.FMSException;
import com.intuit.ipp.services.DataService;
/**
* @author dderose
*
*/
public final class ClassHelper {
private ClassHelper() {
}
public static Class getClassFields() throws FMSException {
Class classObj = new Class();
classObj.setName("Class_name_" + RandomStringUtils.randomAlphanumeric(5));
classObj.setSubClass(false);
classObj.setFullyQualifiedName("Class_name_" + RandomStringUtils.randomAlphanumeric(5));
return classObj;
}
public static Class getClass(DataService service) throws FMSException {
List<Class> classes = (List<Class>) service.findAll(new Class());
if (!classes.isEmpty()) {
return classes.get(0);
}
return createClass(service);
}
private static Class createClass(DataService service) throws FMSException {
return service.add(getClassFields());
}
public static ReferenceType getClassRef(Class classObj) {
ReferenceType classRef = new ReferenceType();
classRef.setName(classObj.getName());
classRef.setValue(classObj.getId());
return classRef;
}
}