Skip to content
Snippets Groups Projects
Commit bd29920e authored by Martin Lowe's avatar Martin Lowe :flag_ca:
Browse files

Add Feature IDs to SolutionVersions #26


Add missing feature ID object.

Change-Id: I778cc86cdc6351d341d7e28d0ad7d2fe6639aa91
Signed-off-by: Martin Lowe's avatarMartin Lowe <martin.lowe@eclipse-foundation.org>
parent aac15864
No related branches found
No related tags found
1 merge request!27Add Feature IDs to SolutionVersions #26
/* Copyright (c) 2019 Eclipse Foundation and others.
* This program and the accompanying materials are made available
* under the terms of the Eclipse Public License 2.0
* which is available at http://www.eclipse.org/legal/epl-v20.html,
* SPDX-License-Identifier: EPL-2.0
*/
package org.eclipsefoundation.marketplace.dto;
import javax.json.bind.annotation.JsonbProperty;
/**
* Represents a feature in a listing solution version.
*
* @author Martin Lowe
*/
public class FeatureId {
@JsonbProperty("feature_id")
private String name;
private String installState;
/**
* @return the featureId
*/
public String getName() {
return name;
}
/**
* @param name the featureId to set
*/
public void setName(String name) {
this.name = name;
}
/**
* @return the installState
*/
public String getInstallState() {
return installState;
}
/**
* @param installState the installState to set
*/
public void setInstallState(String installState) {
this.installState = installState;
}
}
...@@ -22,6 +22,13 @@ public class SolutionVersion { ...@@ -22,6 +22,13 @@ public class SolutionVersion {
private List<String> platforms; private List<String> platforms;
private String minJavaVersion; private String minJavaVersion;
private String updateSiteUrl; private String updateSiteUrl;
private List<FeatureId> featureIds;
public SolutionVersion() {
this.eclipseVersions = new ArrayList<>();
this.platforms = new ArrayList<>();
this.featureIds = new ArrayList<>();
}
/** /**
* @return the versionString * @return the versionString
...@@ -95,4 +102,18 @@ public class SolutionVersion { ...@@ -95,4 +102,18 @@ public class SolutionVersion {
this.updateSiteUrl = updateSiteUrl; this.updateSiteUrl = updateSiteUrl;
} }
/**
* @return the featureIds
*/
public List<FeatureId> getFeatureIds() {
return featureIds;
}
/**
* @param featureIds the featureIds to set
*/
public void setFeatureIds(List<FeatureId> featureIds) {
this.featureIds = featureIds;
}
} }
/* Copyright (c) 2019 Eclipse Foundation and others.
* This program and the accompanying materials are made available
* under the terms of the Eclipse Public License 2.0
* which is available at http://www.eclipse.org/legal/epl-v20.html,
* SPDX-License-Identifier: EPL-2.0
*/
package org.eclipsefoundation.marketplace.dto.converters;
import org.bson.Document;
import org.eclipsefoundation.marketplace.dto.FeatureId;
import org.eclipsefoundation.marketplace.namespace.DatabaseFieldNames;
/**
* Converter implementation for the {@link FeatureId} object.
*
* @author Martin Lowe
*/
public class FeatureIdConverter implements Converter<FeatureId> {
@Override
public FeatureId convert(Document src) {
FeatureId featureId = new FeatureId();
featureId.setName(src.getString(DatabaseFieldNames.FEATURE_ID));
featureId.setInstallState(src.getString(DatabaseFieldNames.INSTALL_STATE));
return featureId;
}
@Override
public Document convert(FeatureId src) {
Document doc = new Document();
doc.put(DatabaseFieldNames.FEATURE_ID, src.getName());
doc.put(DatabaseFieldNames.INSTALL_STATE, src.getInstallState());
return doc;
}
}
...@@ -6,8 +6,11 @@ ...@@ -6,8 +6,11 @@
*/ */
package org.eclipsefoundation.marketplace.dto.converters; package org.eclipsefoundation.marketplace.dto.converters;
import java.util.stream.Collectors;
import org.bson.Document; import org.bson.Document;
import org.eclipsefoundation.marketplace.dto.SolutionVersion; import org.eclipsefoundation.marketplace.dto.SolutionVersion;
import org.eclipsefoundation.marketplace.namespace.DatabaseFieldNames;
/** /**
* Converter implementation for the {@link SolutionVersion} object. * Converter implementation for the {@link SolutionVersion} object.
...@@ -16,6 +19,8 @@ import org.eclipsefoundation.marketplace.dto.SolutionVersion; ...@@ -16,6 +19,8 @@ import org.eclipsefoundation.marketplace.dto.SolutionVersion;
*/ */
public class SolutionVersionConverter implements Converter<SolutionVersion> { public class SolutionVersionConverter implements Converter<SolutionVersion> {
private final FeatureIdConverter featureIdConverter = new FeatureIdConverter();
@Override @Override
public SolutionVersion convert(Document src) { public SolutionVersion convert(Document src) {
SolutionVersion version = new SolutionVersion(); SolutionVersion version = new SolutionVersion();
...@@ -24,7 +29,8 @@ public class SolutionVersionConverter implements Converter<SolutionVersion> { ...@@ -24,7 +29,8 @@ public class SolutionVersionConverter implements Converter<SolutionVersion> {
version.setMinJavaVersion(src.getString("min_java_version")); version.setMinJavaVersion(src.getString("min_java_version"));
version.setUpdateSiteUrl(src.getString("update_site_url")); version.setUpdateSiteUrl(src.getString("update_site_url"));
version.setVersion(src.getString("version")); version.setVersion(src.getString("version"));
version.setFeatureIds(src.getList(DatabaseFieldNames.FEATURE_IDS, Document.class).stream()
.map(featureIdConverter::convert).collect(Collectors.toList()));
return version; return version;
} }
...@@ -36,7 +42,8 @@ public class SolutionVersionConverter implements Converter<SolutionVersion> { ...@@ -36,7 +42,8 @@ public class SolutionVersionConverter implements Converter<SolutionVersion> {
doc.put("min_java_version", src.getMinJavaVersion()); doc.put("min_java_version", src.getMinJavaVersion());
doc.put("update_site_url", src.getUpdateSiteUrl()); doc.put("update_site_url", src.getUpdateSiteUrl());
doc.put("version", src.getVersion()); doc.put("version", src.getVersion());
doc.put(DatabaseFieldNames.FEATURE_IDS,
src.getFeatureIds().stream().map(featureIdConverter::convert).collect(Collectors.toList()));
return doc; return doc;
} }
} }
...@@ -49,6 +49,8 @@ public class UserAgent { ...@@ -49,6 +49,8 @@ public class UserAgent {
private String osVersion; private String osVersion;
private String locale; private String locale;
private String eclipseVersion;
public UserAgent(String userAgent) { public UserAgent(String userAgent) {
Objects.requireNonNull(userAgent); Objects.requireNonNull(userAgent);
...@@ -70,32 +72,46 @@ public class UserAgent { ...@@ -70,32 +72,46 @@ public class UserAgent {
this.enhancements = m.group(4); this.enhancements = m.group(4);
if (MPC_CLIENT_AGENT_NAME.equalsIgnoreCase(name)) { if (MPC_CLIENT_AGENT_NAME.equalsIgnoreCase(name)) {
handleMpc(); handleMpc();
} else if (name.contains("bot")) {
// drop as we don't care about bot properties
} else {
handleWeb();
} }
} }
/**
* Breaks down the different MPC properties into explicit properties that can be
* retrieved via getters built into the class. The expected format is defined
* below:
*
* <p>
* {@code mpc/<mpc version> (Java <java version> <java vendor>; <os name> <os version> <os arch>; <locale>) <eclipse product>/<product version> (<eclipse application>)}
* </p>
*/
private void handleMpc() { private void handleMpc() {
// expected form: (Java <java version> <java vendor>; <os name> <os version> <os
// arch>; <locale>)
List<String> systemPropList = Splitter.on(';').splitToList(systemProperties); List<String> systemPropList = Splitter.on(';').splitToList(systemProperties);
if (systemPropList.size() != 3) { if (systemPropList.size() != 3) {
// TODO throw exception? // TODO throw exception?
} }
// expected form example: Java <java version> <vendor> // expected form example: Java <java version> <vendor>
String javaPropStr = systemPropList.get(0); List<String> javaProps = Splitter.on(' ').limit(3).splitToList(systemPropList.get(0));
String javaPlatform = javaPropStr.substring(javaPropStr.indexOf(' ') + 1); if (javaProps.size() != 3) {
List<String> javaProps = Splitter.on(' ').limit(2).splitToList(javaPlatform); // TODO throw exception?
this.javaVersion = javaProps.get(0); }
this.javaVendor = javaProps.get(1); this.javaVersion = javaProps.get(1);
this.javaVendor = javaProps.get(2);
// expected form: <OS name> <OS version> <??>
String systemPlatform = systemPropList.get(1); // expected form: <OS name> <OS version> <OS arch>
this.locale = systemPropList.get(2); List<String> systemProps = Splitter.on(' ').limit(3).splitToList(systemPropList.get(1));
} if (systemProps.size() != 3) {
// TODO throw exception?
}
this.os = systemProps.get(0);
this.osVersion = systemProps.get(1);
private void handleWeb() { // get the current locale
this.locale = systemPropList.get(2);
// expected form: <eclipse product>/<product version>
List<String> platformProps = Splitter.on('/').limit(3).splitToList(platform);
} }
/** /**
......
...@@ -21,6 +21,7 @@ public final class DatabaseFieldNames { ...@@ -21,6 +21,7 @@ public final class DatabaseFieldNames {
public static final String DOCID = "_id"; public static final String DOCID = "_id";
public static final String URL = "url"; public static final String URL = "url";
public static final String NAME = "name"; public static final String NAME = "name";
public static final String OS = "os";
// listing fields // listing fields
public static final String LISTING_TEASER = "teaser"; public static final String LISTING_TEASER = "teaser";
...@@ -43,7 +44,8 @@ public final class DatabaseFieldNames { ...@@ -43,7 +44,8 @@ public final class DatabaseFieldNames {
public static final String LISTING_TAGS = "tags"; public static final String LISTING_TAGS = "tags";
public static final String CATEGORY_IDS = "category_ids"; public static final String CATEGORY_IDS = "category_ids";
public static final String LISTING_CATEGORIES = "categories"; public static final String LISTING_CATEGORIES = "categories";
public static final String MAINTAINERS = "maintainers"; public static final String FEATURE_ID = "feature_id";
public static final String INSTALL_STATE = "install_state";
// catalog fields // catalog fields
public static final String CATALOG_TABS = "tabs"; public static final String CATALOG_TABS = "tabs";
...@@ -53,6 +55,17 @@ public final class DatabaseFieldNames { ...@@ -53,6 +55,17 @@ public final class DatabaseFieldNames {
public static final String CATALOG_DESCRIPTION = "description"; public static final String CATALOG_DESCRIPTION = "description";
public static final String CATALOG_DEPENDENCIES_REPOSITORY = "dependencies_repository"; public static final String CATALOG_DEPENDENCIES_REPOSITORY = "dependencies_repository";
// category fields
public static final String MARKET_IDS = "market_ids";
public static final String INSTALL_JAVA_VERSION = "java_version";
public static final String INSTALL_VERSION = "version";
public static final String INSTALL_LISTING_ID = "listing_id";
public static final String INSTALL_DATE = "date";
public static final String ECLIPSE_VERSION = "eclipse_version";
public static final String FEATURE_IDS = "feature_ids";
public static final String LOCALE = "locale";
private DatabaseFieldNames() { private DatabaseFieldNames() {
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment