Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
fvilla committed Dec 22, 2024
1 parent 1c563ea commit bb7bb74
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public void exportWithSchema(KlabService service, List<String> arguments) {
public void importWithSchema(KlabService service, String suggestedUrn, List<String> arguments) {

ResourceTransport.Schema schema = null;
Urn result = null;
String result = null;
if (arguments == null || arguments.isEmpty()) {
schema = chooseSchemaInteractively(service.capabilities(user()).getImportSchemata());
if (schema != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.util.Set;
import java.util.logging.Level;

import org.integratedmodelling.klab.api.collections.Pair;
import org.integratedmodelling.klab.api.collections.impl.PairImpl;
import org.integratedmodelling.klab.api.data.mediation.impl.NumericRangeImpl;
import org.integratedmodelling.klab.api.geometry.Geometry;
Expand Down Expand Up @@ -249,7 +250,7 @@ interface Argument extends Serializable {
* @return the collection of errors, each being a pair of <message, level>, or an empty collection if no
* errors occurred
*/
List<PairImpl<String, Level>> validate(ServiceCall function);
List<Pair<String, Level>> validate(ServiceCall function);

/**
* Full synopsis - expecting a multi-line string with full description of options, arguments and
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -456,9 +456,9 @@ ExternalAuthenticationCredentials.CredentialInfo addCredentials(String host,
* properties.
* @param suggestedUrn may be null if the submission does not specify one
* @param scope
* @return
* @return the URN of the asset imported.
*/
Urn importAsset(ResourceTransport.Schema schema, ResourceTransport.Schema.Asset assetCoordinates,
String importAsset(ResourceTransport.Schema schema, ResourceTransport.Schema.Asset assetCoordinates,
String suggestedUrn,
Scope scope);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@
import org.integratedmodelling.klab.api.knowledge.observation.Observation;
import org.integratedmodelling.klab.api.knowledge.organization.Project;
import org.integratedmodelling.klab.api.knowledge.organization.Workspace;
import org.integratedmodelling.klab.api.lang.Annotation;
import org.integratedmodelling.klab.api.lang.Contextualizable;
import org.integratedmodelling.klab.api.lang.Quantity;
import org.integratedmodelling.klab.api.lang.ServiceCall;
import org.integratedmodelling.klab.api.lang.*;
import org.integratedmodelling.klab.api.lang.kactors.KActorsBehavior;
import org.integratedmodelling.klab.api.lang.kim.*;
import org.integratedmodelling.klab.api.provenance.Activity;
Expand Down Expand Up @@ -295,7 +292,8 @@ public static void configureObjectMapperForKlabTypes(ObjectMapper mapper) {
Notification.LexicalContext.class, ResolutionConstraint.class,
KimObservationStrategy.Operation.class, RuntimeAsset.class,
KimObservationStrategy.Filter.class, ObservationStrategy.class,
ObservationStrategy.Operation.class}) {
ObservationStrategy.Operation.class, ServiceInfo.class,
ServiceInfo.Argument.class}) {
module.addSerializer(cls, new PolymorphicSerializer<>());
module.addDeserializer(cls, new PolymorphicDeserializer<>(cls));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.integratedmodelling.common.lang;

import org.integratedmodelling.klab.api.collections.Pair;
import org.integratedmodelling.klab.api.collections.impl.PairImpl;
import org.integratedmodelling.klab.api.documentation.Documentation;
import org.integratedmodelling.klab.api.geometry.Geometry;
Expand Down Expand Up @@ -262,13 +263,13 @@ public List<ServiceInfo.Argument> listArguments() {
}

@Override
public List<PairImpl<String, Level>> validate(ServiceCall function) {
List<PairImpl<String, Level>> ret = new ArrayList<>();
public List<Pair<String, Level>> validate(ServiceCall function) {
List<Pair<String, Level>> ret = new ArrayList<>();
// validate existing arguments
for (String arg : function.getParameters().keySet()) {
ArgumentImpl argument = arguments.get(arg);
if (argument == null) {
ret.add(new PairImpl<>(name + ": argument " + arg + " is not recognized", Level.SEVERE));
ret.add(Pair.of(name + ": argument " + arg + " is not recognized", Level.SEVERE));
} else {
Object val = function.getParameters().get(arg);
// if ((val = classify(val, argument)) == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,14 +476,14 @@ public InputStream exportAsset(String urn, ResourceTransport.Schema schema, Scop
}

@Override
public Urn importAsset(ResourceTransport.Schema schema, ResourceTransport.Schema.Asset assetCoordinates
public String importAsset(ResourceTransport.Schema schema, ResourceTransport.Schema.Asset assetCoordinates
, String suggestedUrn, Scope scope) {

if (schema.getType() == ResourceTransport.Schema.Type.PROPERTIES) {
return new Urn(client.withScope(scope).post(ServicesAPI.IMPORT,
return client.withScope(scope).post(ServicesAPI.IMPORT,
assetCoordinates.getProperties(), String.class,
"schema"
, schema.getSchemaId(), "urn", suggestedUrn));
, schema.getSchemaId(), "urn", suggestedUrn);
} else if (schema.getType() == ResourceTransport.Schema.Type.STREAM) {
var file = assetCoordinates.getFile();
if (file == null && assetCoordinates.getUrl() != null) {
Expand All @@ -497,10 +497,10 @@ public Urn importAsset(ResourceTransport.Schema schema, ResourceTransport.Schema
"does not specify a media type");
}

return new Urn(client.withScope(scope).providing(schema.getMediaTypes())
return client.withScope(scope).providing(schema.getMediaTypes())
.upload(ServicesAPI.IMPORT,
assetCoordinates.getFile(), String.class,
"schema", schema.getSchemaId(), "urn", suggestedUrn));
"schema", schema.getSchemaId(), "urn", suggestedUrn);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ public InputStream exportAsset(String urn, ResourceTransport.Schema schema, Scop
}

@Override
public Urn importAsset(ResourceTransport.Schema schema, ResourceTransport.Schema.Asset assetCoordinates
public String importAsset(ResourceTransport.Schema schema, ResourceTransport.Schema.Asset assetCoordinates
, String suggestedUrn, Scope scope) {
// TODO establish which service we're targeting and route the request to it
if (schema.getType() == ResourceTransport.Schema.Type.PROPERTIES) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.integratedmodelling.klab.api.data.Version;
import org.integratedmodelling.klab.api.knowledge.Artifact;
import org.integratedmodelling.klab.api.knowledge.KlabAsset;
import org.integratedmodelling.klab.api.knowledge.Urn;
import org.integratedmodelling.klab.api.scope.Scope;
import org.integratedmodelling.klab.api.services.KlabService;
import org.integratedmodelling.klab.api.services.resources.adapters.Exporter;
Expand Down Expand Up @@ -41,7 +42,7 @@ public static String importComponentDirect(File file) {
description = "Non-standard Maven repository", optional = true)
})
public static String importComponentMaven(Parameters<String> properties, BaseService service,
Scope scope) {
Scope scope) {

var file = Utils.Maven.synchronizeArtifact(properties.get("groupId", String.class),
properties.get("artifactId", String.class),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,7 @@ public String importAsset(@PathVariable(name = "schema") String schema,
"submissions is available");
}

var result = instance.klabService().importAsset(s, s.asset(data), urn, scope);
return result == null ? null : result.getUrn();
return instance.klabService().importAsset(s, s.asset(data), urn, scope);
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ public InputStream exportAsset(String urn, ResourceTransport.Schema schema, Scop
}

@Override
public Urn importAsset(ResourceTransport.Schema schema, ResourceTransport.Schema.Asset assetCoordinates
public String importAsset(ResourceTransport.Schema schema, ResourceTransport.Schema.Asset assetCoordinates
, String suggestedUrn, Scope scope) {

ServiceCall serviceCall = null;
Expand All @@ -467,6 +467,6 @@ public Urn importAsset(ResourceTransport.Schema schema, ResourceTransport.Schema
}

var languageService = ServiceConfiguration.INSTANCE.getService(Language.class);
return languageService.execute(serviceCall, scope, Urn.class);
return languageService.execute(serviceCall, scope, String.class);
}
}

0 comments on commit bb7bb74

Please sign in to comment.