Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions api/src/org/labkey/api/exp/Identifiable.java
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,6 +17,7 @@

import org.jetbrains.annotations.Nullable;
import org.labkey.api.data.Container;
import org.labkey.api.exp.api.ExpObject;
import org.labkey.api.query.QueryRowReference;
import org.labkey.api.view.ActionURL;

Expand DownExpand Up@@ -47,4 +48,12 @@ default String getLSIDNamespacePrefix()
{
return null;
}

/**
* Get the corresponding ExpObject for this Identifiable, if there is one.
*/
default @Nullable ExpObject getExpObject()
{
return null;
}
}
7 changes: 7 additions & 0 deletions api/src/org/labkey/api/exp/api/ExpObject.java
Original file line numberDiff line numberDiff line change
Expand Up@@ -75,4 +75,11 @@ public interface ExpObject extends Identifiable, Comparable<ExpObject>
* @return Map from PropertyURI to ObjectProperty
*/
Map<String, ObjectProperty> getObjectProperties();

@Override
@Nullable
default ExpObject getExpObject()
{
return this;
}
}
7 changes: 7 additions & 0 deletions experiment/src/org/labkey/experiment/api/Data.java
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,6 +17,7 @@

import org.jetbrains.annotations.Nullable;
import org.labkey.api.exp.api.ExpData;
import org.labkey.api.exp.api.ExpObject;
import org.labkey.api.util.FileUtil;
import org.labkey.api.util.URLHelper;
import org.labkey.api.view.ActionURL;
Expand DownExpand Up@@ -123,4 +124,10 @@ public boolean equals(Object o)

return !(getRowId() == 0 || getRowId() != data.getRowId());
}

@Override
public @Nullable ExpDataImpl getExpObject()
{
return new ExpDataImpl(this);
}
}
7 changes: 7 additions & 0 deletions experiment/src/org/labkey/experiment/api/DataClass.java
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,6 +17,7 @@

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.labkey.api.exp.api.ExpDataClass;
import org.labkey.api.view.ActionURL;
import org.labkey.experiment.controllers.exp.ExperimentController;

Expand DownExpand Up@@ -104,4 +105,10 @@ public int compareTo(@NotNull DataClass o)
{
return getName().compareToIgnoreCase(o.getName());
}

@Override
public @Nullable ExpDataClassImpl getExpObject()
{
return new ExpDataClassImpl(this);
}
}
8 changes: 8 additions & 0 deletions experiment/src/org/labkey/experiment/api/DataInput.java
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,8 +16,10 @@

package org.labkey.experiment.api;

import org.jetbrains.annotations.Nullable;
import org.labkey.api.exp.LsidType;
import org.labkey.api.exp.api.ExpDataRunInput;
import org.labkey.api.exp.api.ExpObject;
import org.labkey.api.settings.AppProps;

import static org.labkey.api.util.PageFlowUtil.encode;
Expand DownExpand Up@@ -67,4 +69,10 @@ protected int getInputKey()
{
return _dataId;
}

@Override
public @Nullable ExpDataRunInputImpl getExpObject()
{
return new ExpDataRunInputImpl(this);
}
}
39 changes: 24 additions & 15 deletions experiment/src/org/labkey/experiment/api/DataProtocolInput.java
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
/*
* Copyright (c) 2018 LabKey Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* Copyright (c) 2018 LabKey Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.labkey.experiment.api;

import org.jetbrains.annotations.Nullable;
import org.labkey.api.exp.api.ExpObject;

public class DataProtocolInput extends AbstractProtocolInput
{
protected Integer _dataClassId;
Expand All@@ -34,4 +37,10 @@ public String getObjectType()
{
return ExpDataImpl.DEFAULT_CPAS_TYPE;
}

@Override
public @Nullable ExpDataProtocolInputImpl getExpObject()
{
return new ExpDataProtocolInputImpl(this);
}
}
9 changes: 9 additions & 0 deletions experiment/src/org/labkey/experiment/api/Experiment.java
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,6 +15,9 @@
*/
package org.labkey.experiment.api;

import org.jetbrains.annotations.Nullable;
import org.labkey.api.exp.api.ExpExperiment;

import java.io.Serializable;

/**
Expand DownExpand Up@@ -101,4 +104,10 @@ public void setBatchProtocolId(Integer batchProtocolId)
{
_batchProtocolId = batchProtocolId;
}

@Override
public @Nullable ExpExperimentImpl getExpObject()
{
return new ExpExperimentImpl(this);
}
}
10 changes: 7 additions & 3 deletions experiment/src/org/labkey/experiment/api/ExperimentRun.java
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,11 +16,9 @@
package org.labkey.experiment.api;

import org.jetbrains.annotations.Nullable;
import org.labkey.api.assay.AssayUrls;
import org.labkey.api.data.Container;
import org.labkey.api.exp.api.ExpProtocol;
import org.labkey.api.exp.api.ExpRun;
import org.labkey.api.exp.api.ExperimentService;
import org.labkey.api.util.PageFlowUtil;
import org.labkey.api.view.ActionURL;
import org.labkey.experiment.controllers.exp.ExperimentController;

Expand DownExpand Up@@ -137,4 +135,10 @@ public int hashCode()
result = 31 * result + (protocolLSID != null ? protocolLSID.hashCode() : 0);
return result;
}

@Override
public @Nullable ExpRunImpl getExpObject()
{
return new ExpRunImpl(this);
}
}
Original file line numberDiff line numberDiff line change
Expand Up@@ -1273,11 +1273,10 @@ public String generateLSID(@NotNull Container container, @NotNull DataType type,
public ExpObject findObjectFromLSID(String lsid)
{
Identifiable id = LsidManager.get().getObject(lsid);
if (id instanceof ExpObject)
{
return (ExpObject) id;
}
return null;
if (id == null)
return null;

return id.getExpObject();
}

@Override
Expand Down
8 changes: 8 additions & 0 deletions experiment/src/org/labkey/experiment/api/Material.java
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,7 +15,9 @@
*/
package org.labkey.experiment.api;

import org.jetbrains.annotations.Nullable;
import org.labkey.api.exp.api.ExpMaterial;
import org.labkey.api.exp.api.ExpObject;
import org.labkey.api.util.URLHelper;
import org.labkey.api.view.ActionURL;
import org.labkey.experiment.controllers.exp.ExperimentController;
Expand DownExpand Up@@ -55,4 +57,10 @@ public int hashCode()
{
return getRowId();
}

@Override
public @Nullable ExpMaterialImpl getExpObject()
{
return new ExpMaterialImpl(this);
}
}
7 changes: 7 additions & 0 deletions experiment/src/org/labkey/experiment/api/MaterialInput.java
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,6 +16,7 @@

package org.labkey.experiment.api;

import org.jetbrains.annotations.Nullable;
import org.labkey.api.exp.LsidType;
import org.labkey.api.exp.api.ExpMaterialRunInput;
import org.labkey.api.settings.AppProps;
Expand DownExpand Up@@ -64,4 +65,10 @@ protected int getInputKey()
{
return _materialId;
}

@Override
public @Nullable ExpMaterialRunInputImpl getExpObject()
{
return new ExpMaterialRunInputImpl(this);
}
}
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,6 +15,9 @@
*/
package org.labkey.experiment.api;

import org.jetbrains.annotations.Nullable;
import org.labkey.api.exp.api.ExpObject;

public class MaterialProtocolInput extends AbstractProtocolInput
{
protected Integer _materialSourceId;
Expand All@@ -34,4 +37,10 @@ public String getObjectType()
{
return ExpMaterialImpl.DEFAULT_CPAS_TYPE;
}

@Override
public @Nullable ExpMaterialProtocolInputImpl getExpObject()
{
return new ExpMaterialProtocolInputImpl(this);
}
}
7 changes: 7 additions & 0 deletions experiment/src/org/labkey/experiment/api/MaterialSource.java
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,6 +17,8 @@

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.labkey.api.exp.api.ExpObject;
import org.labkey.api.exp.api.ExpSampleType;
import org.labkey.api.exp.query.ExpSampleTypeTable;
import org.labkey.api.exp.query.ExpSchema;
import org.labkey.api.query.FieldKey;
Expand DownExpand Up@@ -169,4 +171,9 @@ public int compareTo(@NotNull MaterialSource o)
return getName().compareToIgnoreCase(o.getName());
}

@Override
public @Nullable ExpSampleTypeImpl getExpObject()
{
return new ExpSampleTypeImpl(this);
}
}
8 changes: 7 additions & 1 deletion experiment/src/org/labkey/experiment/api/Protocol.java
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,14 +16,15 @@
package org.labkey.experiment.api;

import org.apache.commons.beanutils.BeanUtils;
import org.jetbrains.annotations.Nullable;
import org.labkey.api.exp.ObjectProperty;
import org.labkey.api.exp.OntologyManager;
import org.labkey.api.exp.PropertyType;
import org.labkey.api.exp.ProtocolParameter;
import org.labkey.api.exp.api.ExpProtocol;
import org.labkey.api.exp.api.ExpProtocolInput;

import java.lang.reflect.InvocationTargetException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
Expand DownExpand Up@@ -411,4 +412,9 @@ public List<? extends ExpProtocolInputImpl> retrieveProtocolInputs()
return _protocolInputs;
}

@Override
public @Nullable ExpProtocolImpl getExpObject()
{
return new ExpProtocolImpl(this);
}
}
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,6 +15,8 @@
*/
package org.labkey.experiment.api;

import org.jetbrains.annotations.Nullable;
import org.labkey.api.exp.api.ExpObject;
import org.labkey.api.exp.api.ExpProtocol;
import org.labkey.api.exp.IdentifiableBase;

Expand DownExpand Up@@ -155,4 +157,9 @@ public void setEndTime(Date endTime)

}

@Override
public @Nullable ExpProtocolApplicationImpl getExpObject()
{
return new ExpProtocolApplicationImpl(this);
}
}
Original file line numberDiff line numberDiff line change
Expand Up@@ -4627,10 +4627,6 @@ public boolean handlePost(SetFlagForm form, BindException errors) throws Excepti
throw new UnauthorizedException();
}

if (!container.hasPermission(getUser(), UpdatePermission.class))
{
throw new UnauthorizedException();
}
obj.setComment(getUser(), form.getComment());

if (form.isRedirect())
Expand Down