Skip to content

Commit

Permalink
Merge branch 'main' into filtered-hierarchies
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewhorridge committed Dec 2, 2024
2 parents cc82c29 + c910578 commit 15620db
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<groupId>edu.stanford.protege</groupId>
<artifactId>webprotege-backend-service</artifactId>
<version>1.3.12</version>
<version>1.3.14</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import edu.stanford.protege.webprotege.common.ProjectId;
import org.bson.Document;
import org.bson.conversions.Bson;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.mongodb.core.MongoTemplate;

import javax.annotation.*;
Expand Down Expand Up @@ -54,6 +56,8 @@ public class EntityFormRepositoryImpl implements EntityFormRepository {

private final Lock writeLock = readWriteLock.writeLock();

private final static Logger LOGGER = LoggerFactory.getLogger(EntityFormRepositoryImpl.class);

@Inject
public EntityFormRepositoryImpl(ObjectMapper objectMapper, MongoTemplate database) {
this.objectMapper = checkNotNull(objectMapper);
Expand Down Expand Up @@ -131,17 +135,22 @@ public void setProjectFormDescriptors(@Nonnull ProjectId projectId, @Nonnull Lis
try {
writeLock.lock();
var collection = getCollection();
collection.deleteMany(new Document(PROJECT_ID, projectId.id()));
var docs = new ArrayList<Document>();

if (!formDescriptors.isEmpty()) {
var docs = new ArrayList<Document>();
for (int ordinal = 0; ordinal < formDescriptors.size(); ordinal++) {
var formDescriptor = formDescriptors.get(ordinal);
var record = FormDescriptorRecord.get(projectId, formDescriptor, ordinal);
var recordDocument = objectMapper.convertValue(record, Document.class);
docs.add(recordDocument);
}
}
collection.deleteMany(new Document(PROJECT_ID, projectId.id()));
if (!docs.isEmpty()) {
collection.insertMany(docs);
}
}catch (Exception e) {
LOGGER.error("Error saving forms for project " + projectId.id(), e);
} finally {
writeLock.unlock();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ void shouldCreateAndInitPermissionsOnNewEmptyProject() throws InterruptedExcepti
"en",
"TheProjectDescription");
manager.execute(newProjectSettings, executionContext);
Thread.sleep(300);
Thread.sleep(600);
verify(projectPermissionsInitializer, times(1)).applyDefaultPermissions(any(ProjectId.class),
eq(janeDoe));
}
Expand Down

0 comments on commit 15620db

Please sign in to comment.