diff --git a/README.md b/README.md
index 9e120b4..2dd6e52 100644
--- a/README.md
+++ b/README.md
@@ -20,7 +20,15 @@
1. After cloning this git repository, go the root folder of the repo.
2. run `npm run build:elements-prod` to build the project. This will produce a `dist` with artefacts
3. Copy the `dist` folder to under `/src/main/webapp/static/` of your web project. That is, you will have a number of js/css files under the folder `/src/main/webapp/static/dist/oslc-ui`
-4. Use generated `/dist/oslc-ui/java-gen/*` classes for your Java app
+4. Add the following dependency to your Java app:
+
+```
+
+ org.eclipse.lyo.server
+ oslc-ui-model
+ 4.1.0-SNAPSHOT
+
+```
### oslc-selector
diff --git a/includes/PreviewFactory.java b/includes/PreviewFactory.java
deleted file mode 100644
index 981524e..0000000
--- a/includes/PreviewFactory.java
+++ /dev/null
@@ -1,121 +0,0 @@
-
-package org.eclipse.lyo.oslc_ui;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import org.apache.commons.lang3.StringUtils;
-import org.eclipse.lyo.oslc4j.core.annotation.OslcName;
-import org.eclipse.lyo.oslc4j.core.annotation.OslcOccurs;
-import org.eclipse.lyo.oslc4j.core.annotation.OslcPropertyDefinition;
-import org.eclipse.lyo.oslc4j.core.annotation.OslcValueType;
-import org.eclipse.lyo.oslc4j.core.model.AbstractResource;
-import org.eclipse.lyo.oslc4j.core.model.Link;
-import org.eclipse.lyo.oslc4j.core.model.Occurs;
-import org.eclipse.lyo.oslc4j.core.model.ValueType;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-public class PreviewFactory {
-
- public static Preview getPreview(final AbstractResource aResource, List getterMethodNames, boolean showPropertyHeadingsAsLinks) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
- ArrayList previewItems = new ArrayList();
- Method getterMethod;
- for (String getterMethodName : getterMethodNames) {
- getterMethod = aResource.getClass().getMethod(getterMethodName);
- boolean multiple = getterMethod.getAnnotation(OslcOccurs.class).value().equals(Occurs.ZeroOrMany) || getterMethod.getAnnotation(OslcOccurs.class).value().equals(Occurs.OneOrMany);
- boolean showPropertyValueAsLink = (null != getterMethod.getAnnotation(OslcValueType.class)) && (getterMethod.getAnnotation(OslcValueType.class).value().equals(ValueType.Resource));
- PropertyDefintion key;
- if (showPropertyHeadingsAsLinks) {
- key = constructPropertyDefintion(getterMethod.getAnnotation(OslcPropertyDefinition.class).value(), getterMethod.getAnnotation(OslcName.class).value());
- }
- else {
- key = constructPropertyDefintion(getterMethod.getAnnotation(OslcName.class).value());
- }
- PropertyValue value;
- if (showPropertyValueAsLink) {
- if (multiple) {
- Collection links = (Collection) getterMethod.invoke(aResource);
- List l = new ArrayList();
- for(Link link : links) {
- l.add(constructLink(link));
- }
- value = constructPropertyValue(PropertyDefintion.RepresentationType.LINK, multiple, l);
- }
- else {
- Link link = (Link) getterMethod.invoke(aResource);
- value = constructPropertyValue(PropertyDefintion.RepresentationType.LINK, multiple, constructLink(link));
- }
- }
- else {
- value = constructPropertyValue(PropertyDefintion.RepresentationType.TEXT, multiple, getterMethod.invoke(aResource));
- }
- previewItems.add(constructProperty(key, value));
- }
- Preview oslcPreviewDataSet = new Preview();
- oslcPreviewDataSet.setProperties(previewItems);
- return oslcPreviewDataSet;
- }
-
- public static String getPreviewAsJsonString(final AbstractResource aResource, List getterMethodNames, boolean showPropertyHeadingsAsLinks) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException, JsonProcessingException {
- Preview preview = PreviewFactory.getPreview(aResource, getterMethodNames, showPropertyHeadingsAsLinks);
- ObjectMapper mapper = new ObjectMapper();
- String previewAsString = mapper.writeValueAsString(preview);
- return previewAsString;
- }
-
-
- private static Property constructProperty(PropertyDefintion propertyDefintion, PropertyValue propertyValue) {
- Property item = new Property();
- item.setPropertyDefintion(propertyDefintion);
- item.setPropertyValue(propertyValue);
- return item;
- }
-
- private static PropertyValue constructPropertyValue(PropertyDefintion.RepresentationType representationType, Boolean representAsList, Object data) {
- PropertyValue value = new PropertyValue();
- value.setRepresentationType(representationType);
- value.setRepresentAsList(representAsList);
- if (null == data) {
- value.setData("");
- }
- else {
- value.setData(data);
- }
- return value;
- }
-
- private static PropertyDefintion getPropertyDefintion(PropertyDefintion.RepresentationType representationType, Object data) {
- PropertyDefintion key = new PropertyDefintion();
- key.setRepresentationType(representationType);
- key.setData(data);
- return key;
- }
- private static PropertyDefintion constructPropertyDefintion(String dataAsString) {
- return getPropertyDefintion(PropertyDefintion.RepresentationType.TEXT, dataAsString);
- }
- private static PropertyDefintion constructPropertyDefintion(String linkUri, String linkTitle) {
- return getPropertyDefintion(PropertyDefintion.RepresentationType.LINK, constructLink(linkUri, linkTitle));
- }
-
- private static org.eclipse.lyo.oslc_ui.Link constructLink(Link link) {
- if (null == link) {
- return null;
- }
- if (StringUtils.isBlank(link.getLabel())) {
- return constructLink(link.getValue().toString(), link.getValue().toString());
- }
- else {
- return constructLink(link.getValue().toString(), link.getLabel());
- }
- }
-
- private static org.eclipse.lyo.oslc_ui.Link constructLink(String link, String title) {
- org.eclipse.lyo.oslc_ui.Link l = new org.eclipse.lyo.oslc_ui.Link();
- l.setLink(link);
- l.setTitle(title);
- return l;
- }
-}
diff --git a/package.json b/package.json
index 74dfae0..3b12cfe 100644
--- a/package.json
+++ b/package.json
@@ -11,7 +11,7 @@
"create-link-schema": "ts-json-schema-generator --type Link --tsconfig ./tsconfig.json --path \"./src/app/preview/models.ts\" > src/link-schemas.json",
"create-java-preview-classes": "./libs/jsonschema2pojo-1.0.2/bin/jsonschema2pojo --source \"src/preview-schemas.json\" --target dist/oslc-ui/java-gen -p org.eclipse.lyo.oslc_ui",
"create-java-link-classes": "./libs/jsonschema2pojo-1.0.2/bin/jsonschema2pojo --source \"src/link-schemas.json\" --target dist/oslc-ui/java-gen -p org.eclipse.lyo.oslc_ui",
- "generate": "npm run create-preview-schema && npm run create-link-schema && npm run create-java-preview-classes && npm run create-java-link-classes && cp includes/PreviewFactory.java dist/oslc-ui/java-gen/org/eclipse/lyo/oslc_ui/",
+ "generate": "npm run create-preview-schema && npm run create-link-schema && npm run create-java-preview-classes && npm run create-java-link-classes",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"