Changeset 6780 for extensions/net.sf.basedb.relax/trunk
- Timestamp:
- Jun 17, 2022, 1:38:12 PM (16 months ago)
- Location:
- extensions/net.sf.basedb.relax/trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/net.sf.basedb.relax/trunk/README
r6778 r6780 3 3 1. BASE 3.19 or later. 4 4 2. Java 11 or later. 5 3. Open Grid Scheduler extension 1.3must be installed.5 3. Job Scheduler extension 1.6 must be installed. 6 6 4. External files extension 1.5 must be installed. 7 7 -
extensions/net.sf.basedb.relax/trunk/src/net/sf/basedb/relax/plugins/ReleaseImporterPlugin.java
r5557 r6780 65 65 import net.sf.basedb.core.Type; 66 66 import net.sf.basedb.core.Unit; 67 import net.sf.basedb.core.Annotation.Source; 67 68 import net.sf.basedb.core.Job.ExecutionTime; 68 69 import net.sf.basedb.core.MultiPermissions; … … 612 613 private Map<String, AnnotationTypeCategory> categories; 613 614 private Map<String, AnnotationType> annotationTypes; 615 private Map<String, Set<Integer>> projectsWithAnnotationType; 614 616 private Map<String, Map<String, ?>> lookups; 615 617 private Set<String> newAnnotationTypes; … … 642 644 lookups = new HashMap<>(); 643 645 newAnnotationTypes = new HashSet<>(); 646 projectsWithAnnotationType = new HashMap<>(); 644 647 fileTypes = new HashMap<>(); 645 648 namedItems = new HashMap<>(); … … 847 850 for (AnnotationType at : annotationTypes.values()) 848 851 { 849 if (at.getProjectKey().getProjectIds(Permission.READ).size() == 1) 852 Set<Integer> inProjects = at.getProjectKey().getProjectIds(Permission.READ); 853 projectsWithAnnotationType.put(at.getName(), inProjects); 854 if (inProjects.size() == 1) 850 855 { 851 856 newAnnotationTypes.add(at.getName()); … … 952 957 Object aValue = jsonAnnotation.get("value"); 953 958 Map<String, ?> indexLookup = lookups.get(aName); 954 if ( indexLookup!= null)959 if (aValue != null) 955 960 { 956 aValue = indexLookup.get((String)aValue); 957 } 958 Type valueType = at.getValueType(); 959 if (valueType == Type.DATE) 960 { 961 aValue = dateFormat.convert((String)aValue); 962 } 963 else if (valueType == Type.TIMESTAMP) 964 { 965 aValue = dateTimeFormat.convert((String)aValue); 966 } 967 else if (valueType.isNumerical()) 968 { 969 aValue = valueType.convertNumber((Number)aValue); 961 if (indexLookup != null) 962 { 963 aValue = indexLookup.get((String)aValue); 964 } 965 Type valueType = at.getValueType(); 966 if (valueType == Type.DATE) 967 { 968 aValue = dateFormat.convert((String)aValue); 969 } 970 else if (valueType == Type.TIMESTAMP) 971 { 972 aValue = dateTimeFormat.convert((String)aValue); 973 } 974 else if (valueType.isNumerical()) 975 { 976 aValue = valueType.convertNumber((Number)aValue); 977 } 970 978 } 971 979 … … 985 993 else 986 994 { 987 if ((isNewItem || isNewAnnotationType) && projectAnnotations) 995 if (aValue == null) 996 { 997 // If there is no value for a project-specific annotation we 998 // may have to convert an existing default annotation to 999 // project-specific annotations for all releases the current 1000 // item is part of that doesn't have a project-specific value already 1001 log(" Annotation with null: "+aName); 1002 if (projectAnnotations && !isNewItem & !isNewAnnotationType && aSet.hasProjectAnnotation(at, Source.PRIMARY, null)) 1003 { 1004 //log(" Annotation " + (isNew ? "created" : "updated") + ": " + aName + (a.getProjectId() !=0 ? " (project-specific)" : "" )); 1005 Annotation aDefault = aSet.getProjectAnnotation(at, null); 1006 List<?> defaultValues = aDefault.getValues(); 1007 aSet.removeProjectAnnotation(at, null); 1008 log(" Annotation removed: " + aName + " (project-default)"); 1009 Set<Integer> itemProjects = ((SharedItem)aItem).getProjectKey().getProjectIds(Permission.READ); 1010 Set<Integer> annotationProjects = projectsWithAnnotationType.get(aName); 1011 //itemProjects.retainAll(projectsWithAnnotationType.get(aName)); 1012 for (int pid : itemProjects) 1013 { 1014 Project p = Project.getById(dc, pid); 1015 if (annotationProjects.contains(pid) && pid != currentProject.getId()) 1016 { 1017 Annotation aProject = aSet.getProjectAnnotation(at, p); 1018 if (!aProject.isInDatabase()) 1019 { 1020 aProject.setValuesIfDifferent(defaultValues, null); 1021 log(" Annotation created: " + aName + " (project-specific: " + p.getName() + ")"); 1022 } 1023 } 1024 else 1025 { 1026 log(" Annotation not copied: " + aName + " (project-specific: " + p.getName() + ")"); 1027 } 1028 } 1029 } 1030 } 1031 else if ((isNewItem || isNewAnnotationType) && projectAnnotations) 988 1032 { 989 1033 // Always set default value
Note: See TracChangeset
for help on using the changeset viewer.