Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools for migrating codex data into wildbook #652

Merged
merged 32 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
ec47875
alpha
naknomum Jul 16, 2024
1bc41b7
db props
naknomum Jul 16, 2024
7b25e95
beta create user
naknomum Jul 16, 2024
42722e1
some MediaAssets why not
naknomum Jul 17, 2024
a1e23be
Merge branch 'master' into codex_migrator
naknomum Jul 18, 2024
eb64b30
roles + misc
naknomum Jul 18, 2024
c0738d6
annots
naknomum Jul 18, 2024
8c45785
encounters (wip)
naknomum Jul 22, 2024
822848c
child assets, take 1
naknomum Jul 24, 2024
0597eb7
hacky skip of auto-index search
naknomum Jul 24, 2024
3962711
duplicate blocking
naknomum Jul 24, 2024
d8e6683
hacky pt 2
naknomum Jul 24, 2024
199e3bc
some cleanup, batching, and occurrences
naknomum Jul 24, 2024
027693c
MarkedIndividuals
naknomum Jul 24, 2024
c262634
how in the heck have we survived this long with this not supporting s…
naknomum Jul 24, 2024
0435602
siteSettings / taxonomy support
naknomum Jul 24, 2024
931c1a8
names (alpha) and other indiv stuff
naknomum Jul 24, 2024
72a25f4
location fu, other fields
naknomum Jul 24, 2024
e74dbb3
customField insanity... maybe
naknomum Jul 25, 2024
6299153
some indivs stuff
naknomum Jul 25, 2024
0beef2f
bugfixes; better Feature handling; timezones-ish
naknomum Jul 25, 2024
a007c2e
migrate Keywords
naknomum Jul 26, 2024
774fa2e
relationships (alpha)
naknomum Jul 26, 2024
f71d5ef
why not have a Relationship.toString()
naknomum Jul 26, 2024
09c3467
do not create duplicate
naknomum Jul 26, 2024
7ec6a6b
fix autogen names... maybe?
naknomum Jul 26, 2024
592be06
smtp support via postfix docker container
naknomum Jul 29, 2024
4e5b4dd
better default outgoing emails
naknomum Jul 29, 2024
0d390e4
bugfix on enc ownership; socialgroup migration (wip)
naknomum Jul 30, 2024
9d01cf6
SocialGroup
naknomum Jul 30, 2024
5a56ff1
migratePendingSightings (WIP)
naknomum Jul 31, 2024
a1a9170
Merge branch 'master' into codex_migrator
naknomum Jul 31, 2024
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
2 changes: 2 additions & 0 deletions devops/development/.dockerfiles/smtp/dkim-keys/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
your DKIM keys should go in here
see: https://hub.docker.com/r/boky/postfix/
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ allowAdoptions = false

#email addresses and parameters
sendEmailNotifications=true
autoEmailAddress=info@wildbook.org
newSubmissionEmail=donotreply@wildbook.org
mailHost=localhost
autoEmailAddress=noreply@wildme.org
newSubmissionEmail=noreply@wildme.org
mailHost=smtp
removeEmailString=Do you want to REMOVE your email address from this database? Click the link below to remove it. You will no longer receive updates on your encounters.

#HTML metadata for each page
Expand Down
8 changes: 8 additions & 0 deletions devops/development/_env.template
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
WILDBOOK_BASE_DIR=~/wildbook-dev


# for smtp (postfix) usage:
MAIL_HOSTNAME=example.com
MAIL_ALLOWED_SENDER_DOMAINS=example.com
MAIL_PORT=1587
MAIL_RELAYHOST=example.com:587
MAIL_RELAYHOST_USERNAME=changeme
MAIL_RELAYHOST_PASSWORD=changeme



# these rest of these settings are fine for a development environment, but can be changed if you desire
Expand Down
17 changes: 17 additions & 0 deletions devops/development/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,23 @@ services:
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
- "OPENSEARCH_INITIAL_ADMIN_PASSWORD=${OPENSEARCH_INITIAL_ADMIN_PASSWORD}"

# https://hub.docker.com/r/boky/postfix/
# TODO dkim and spf needs to be added/supported
smtp:
image: boky/postfix
networks:
- intranet
ports:
- $MAIL_PORT:587
volumes:
- .dockerfiles/smtp/dkim-keys:/etc/opendkim/keys
environment:
- "HOSTNAME=${MAIL_HOSTNAME}"
- "ALLOWED_SENDER_DOMAINS=${MAIL_ALLOWED_SENDER_DOMAINS}"
- "RELAYHOST=${MAIL_RELAYHOST}"
- "RELAYHOST_USERNAME=${MAIL_RELAYHOST_USERNAME}"
- "RELAYHOST_PASSWORD=${MAIL_RELAYHOST_PASSWORD}"

autoheal:
image: willfarrell/autoheal
volumes:
Expand Down
10 changes: 8 additions & 2 deletions src/main/java/org/ecocean/Encounter.java
Original file line number Diff line number Diff line change
Expand Up @@ -1427,6 +1427,12 @@ public boolean hasMarkedIndividual() {
return (individual != null);
}

public boolean hasMarkedIndividual(MarkedIndividual match) {
if (match == null) return false;
if (individual == null) return false;
return (match.getId().equals(individual.getId()));
}

public void assignToMarkedIndividual(MarkedIndividual indiv) {
setIndividual(indiv);
}
Expand Down Expand Up @@ -2989,13 +2995,13 @@ public void setAnnotations(ArrayList<Annotation> anns) {
public void addAnnotations(List<Annotation> anns) {
if (annotations == null) annotations = new ArrayList<Annotation>();
for (Annotation ann : anns) {
annotations.add(ann);
if (!annotations.contains(ann)) annotations.add(ann);
}
}

public void addAnnotation(Annotation ann) {
if (annotations == null) annotations = new ArrayList<Annotation>();
annotations.add(ann);
if (!annotations.contains(ann)) annotations.add(ann);
}

public void useAnnotationsForMatching(boolean use) {
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/org/ecocean/MarkedIndividual.java
Original file line number Diff line number Diff line change
Expand Up @@ -1129,7 +1129,11 @@ public void setTaxonomyString(String tax) {
setSpecificEpithet(tax);
} else {
setGenus(parts[0]);
setSpecificEpithet(parts[1]);
String ep = parts[1];
for (int i = 2 ; i < parts.length ; i++) {
ep += " " + parts[i];
}
setSpecificEpithet(ep);
}
}

Expand Down
23 changes: 8 additions & 15 deletions src/main/java/org/ecocean/Occurrence.java
Original file line number Diff line number Diff line change
Expand Up @@ -155,22 +155,15 @@ public Occurrence(String occurrenceID) {
System.out.println("Created new occurrence with only ID" + this.occurrenceID);
}

public boolean hasEncounter(Encounter enc) {
return ((encounters != null) && encounters.contains(enc));
}

public boolean addEncounter(Encounter enc) {
if (encounters == null) { encounters = new ArrayList<Encounter>(); }
// prevent duplicate addition
boolean isNew = true;
for (int i = 0; i < encounters.size(); i++) {
Encounter tempEnc = (Encounter)encounters.get(i);
if (tempEnc.getEncounterNumber().equals(enc.getEncounterNumber())) {
return false;
}
}
if (isNew) {
encounters.add(enc);
// updateNumberOfEncounters();
}
// if((locationID!=null) && (enc.getLocationID()!=null)&&(!enc.getLocationID().equals("None"))){this.locationID=enc.getLocationID();}
return isNew;
if (encounters == null) encounters = new ArrayList<Encounter>();
if (encounters.contains(enc)) return false;
encounters.add(enc);
return true;
}

// private void updateNumberOfEncounters() {
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/org/ecocean/OpenSearch.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ public static boolean isValidIndexName(String indexName) {
return Arrays.asList(VALID_INDICES).contains(indexName);
}

public static boolean skipAutoIndexing() {
return new java.io.File("/tmp/skipAutoIndexing").exists();
}

// http://localhost:9200/encounter/_search?pretty=true&q=*:*
// http://localhost:9200/_cat/indices?v

Expand Down
6 changes: 6 additions & 0 deletions src/main/java/org/ecocean/WildbookLifecycleListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import javax.jdo.listener.*;
import org.datanucleus.enhancement.Persistable;
import org.ecocean.Base;
import org.ecocean.OpenSearch;

// https://www.datanucleus.org/products/accessplatform_4_1/jdo/lifecycle_callbacks.html#listeners

Expand Down Expand Up @@ -40,6 +41,11 @@ public void preStore(InstanceLifecycleEvent event) {}
public void postStore(InstanceLifecycleEvent event) {
Persistable obj = (Persistable)event.getSource();

if (OpenSearch.skipAutoIndexing()) {
System.out.println("WildbookLifecycleListener skipAutoIndexing set");
return;
}

System.out.println("WildbookLifecycleListener postStore() event type=" +
event.getEventType() + "; source=" + obj + "; target=" + event.getTarget() +
"; detachedInstance=" + event.getDetachedInstance() + "; persistentInstance=" +
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/org/ecocean/social/Relationship.java
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,11 @@ public void setBidirectional(Boolean direction) {
if (direction != null) { bidirectional = direction; } else { bidirectional = null; }
}

public String toString() {
return this.type + ": " + this.individual1.getId() + "[" + this.getMarkedIndividualRole1() + "] + " +
this.individual2.getId() + "[" + this.getMarkedIndividualRole2() + "]";
}

public JSONObject decorateJson(HttpServletRequest request, JSONObject jobj)
throws JSONException {
if (individual1 != null) jobj.put("individual1", this.individual1.uiJson(request, false));
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/bundles/codexMigration.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
codexDbUrl=jdbc:postgresql://localhost:5432/codex
codexDbUsername=example
codexDbPassword=example
Loading
Loading