public class ProjectService extends Object
Strates > Traits > Captures > Tailles
Modifier and Type | Field and Description |
---|---|
protected CommandService |
commandService |
protected CommonService |
commonService |
protected CoserBusinessConfig |
config |
protected PublicationService |
publicationService |
Constructor and Description |
---|
ProjectService(CoserBusinessConfig config) |
Modifier and Type | Method and Description |
---|---|
protected void |
addHistoryCommandsToProperties(Properties props,
List<Command> historyCommand,
String propertyPrefix)
Sauve une liste ordonnées de commande dans le fichier specifié.
|
protected void |
addProjectContent(Project project,
AbstractDataContainer container,
CoserConstants.Category category,
DataStorage content,
boolean deletedContent)
Set content into project depending on category type.
|
protected String |
convertCommandToLine(Command command)
Convert a command to string info
|
protected Command |
convertLineToCommand(String line)
Convert a string line to parameterized command.
|
protected Selection |
copyControlDataToSelection(Project project,
Selection selection)
Copy loaded control data to new created selection.
|
Project |
createProject(Project project,
Map<CoserConstants.Category,File> categoriesAndFiles,
List<File> maps,
ProgressMonitor progress)
Create new project.
|
void |
createProjectSelection(Project project,
Selection selection)
Create and save project selection.
|
void |
deleteData(Project project,
Control control,
CoserConstants.Category category,
String index)
Supprime une données via son index.
|
void |
deleteData(Project project,
Control control,
CoserConstants.Category category,
String index,
String commandUUID)
Supprime une données via son index.
|
void |
deleteRSufiResult(Project project,
Selection selection,
RSufiResult rsufiResult)
Delete a rsufi result.
|
void |
editRsufiResults(Project project,
Selection selection,
RSufiResult rsufiResult,
List<File> othersFile)
Save existing rsufi result.
|
void |
editSelectionOptions(Project project,
Selection selection,
List<File> othersFile)
Save existing rsufi result.
|
File |
extractRSUfiData(Project project,
Selection selection,
File directory,
boolean onlyDataTable)
Extrait les données de la selection pour rSufi.
|
void |
fillLengthStructureMatrix(Project project,
AbstractDataContainer dataContainer,
org.nuiton.math.matrix.MatrixND matrix)
Length structure matrix provider filler part.
|
protected void |
fillListSpeciesFile(Selection selection,
File ouputFile)
Ecrit le fichier ListEspeces.txt dans le fichier specifiés.
|
void |
fillListsSelection(Selection selection,
List<String> selectedSpeciesOccDens,
List<String> selectedSpeciesSizeAllYear,
List<String> selectedSpeciesMaturity)
Definie dans la selection les listes L2 à L4 avec les 3 listes
en parametres.
|
void |
filterDataSpecies(Project project,
Selection selection,
List<String> selectedSpecies)
Update data to remove non selected species.
|
void |
filterDataStrata(Project project,
Selection selection,
List<String> selectedStrata)
Update data to remove non selected strata.
|
List<String> |
filterDataYearsAndGetStrata(Project project,
Selection selection,
List<String> selectedYears)
Filter data on selected years and return resulting strata name sorted
by names.
|
org.nuiton.math.matrix.MatrixND |
getDensity(Project project,
Selection selection)
Densité: nombre par km2 par espèce par année
years=sort(unique(TRAITS$Annee))
#surface total pour toutes les strates
totsurface=sum(STRATES$Surface)
#ordonner table STRATES par nom des strates
STRATES=STRATES[order(STRATES$Strate),]
#combiner les 3 tables de données dans une seule table tab
tab=merge(CAPTURES,STRATES,by.x=c("Annee","Trait"),by.y=c("Annee","Trait"))
tab=merge(tab,TRAITS, by.x=c("Annee","Trait"),by.y=c("Annee","Trait"))
species=sort(unique(CAPTURES$Espece))
#calculer la densité moyenne par année par strate par espèce
densparstrate=tapply(tab$Nombre/tab$SurfaceBalayee,list(tab$Espece, tab$Annee, tab$Strate), mean)
densparstrate[is.na(densparstrate)]=0 # remplace NA par 0
#surface par annee et strate et espèce
surfaceparstrate=tapply(tab$Surface, list(tab$Espece, tab$Annee, tab$Strate), unique)
#multiplier la densité par la surface de la strate pour obtenir nombre par année-strate
nombreparstrate= surfaceparstrate* densparstrate
#sommer nombre sur strates par année pour chaque espèce et diviser par surface totale
densiteparannee=apply(nombreparstrate,c(1,2),sum)/totsurface
#densité moyenne pour la période
densitemoyenneespece=apply(densiteparanne,1,mean)
|
protected double |
getHalfStepValue(double value)
Retourne la valeur au demi pas la plus proche.
|
protected List<Command> |
getHistoryCommandsFromProperties(Properties props,
String propertyPrefix)
Load history command list from file.
|
org.nuiton.math.matrix.MatrixND |
getLengthStructure(Project project,
AbstractDataContainer dataContainer)
Présentation du graphique : histogramme de distribution en tailles par
espèce, par strate et par année (une planche par espèce et par année)
pour toute la série.
|
org.nuiton.math.matrix.MatrixND |
getOccurrence(Project project,
Selection selection)
Occurrence : pourcentage des traits dans lesquels une espèce est présentes
years=seq(min(CAPTURES$Annee), max(CAPTURES$Annee))
nyears=length(years)
catch=CAPTURES[CAPTURES$Nombre>0,] #prendre seulement données positives
#compter nombre de traits par année où chaque espèce est présent
occurence=tapply(catch$Trait,list(species=catch$Espece,year=catch$Annee),lengthunique)
occurrence[is.na(occurence)]<-0
rapport.func=function(x,v) {return (x/v);}
#diviser nombre de traits avec présence par nombre total de traits
pct.occur=apply(occurence,1,rapport.func,v=haulcount)# haulcount de 1)
pct.occur=t(round(pct.occur*100,2)) # multiplier par 100 et arrondir à 2 décimales
colnames(pct.occur)=colnames(haulcount) #affectation noms colonnes matrice
rownames(pct.occur)=rownames(occur) #nom des espèces
#calculerl l'occurrence moyenne à travers les années
provi.oc=round(apply(pct.occur,1,mean),2)
pct.occur=cbind(pct.occur,MeanOccurence=provi.oc)
|
protected DataStorage |
getProjectContent(Project project,
AbstractDataContainer container,
CoserConstants.Category category,
boolean deletedContent)
Set content into project depending on category type.
|
List<String> |
getProjectNames()
Return existing project name list sorted by project name.
|
List<String> |
getProjectSpecies(AbstractDataContainer container,
Project project,
Collection<String> filterSpecyType)
Get species name in project with data in [
beginYear -endYear ]. |
Map<String,String> |
getProjectSpeciesTypes(Project project)
Retourne la liste des type d'especes definie dans le projet sous forme
de map avec leur commentaire (sauf "Tous").
|
String |
getProjectSurveyName(File resultDirectory,
RSufiResult rSufiResult)
Look for project survey name in rsufi result.
|
List<String> |
getProjectYears(Selection selection)
Find all defined year in model.
|
LinkedHashMap<String,String> |
getReftaxSpeciesDisplayFieldMap(Project project,
boolean outputField)
Retourne une map de transcription entre la valeur de stockage de l'espece
et la valeur retranscrite à l'utilisateur suivant les préférences qu'il
a renseigner dans le projet.
|
RSufiResult |
getRSufiResult(File resultDirectory)
Retourne un object
RSufiResult initialise avec les données
du resultat du répertoire demandé. |
org.nuiton.math.matrix.MatrixND |
getSamplingEffort(Project project,
Selection selection)
Effort d'échantillonnage: nombre de traits par strate par année.
|
SortedMap<String,List<String>> |
getSelectionByProject()
Retourne une map de toutes les selections par projet dans le but de
selectionner une selection pour la rejouer dans l'ui.
|
Collection<String> |
getSpeciesWithMaturity(Selection selection)
Recherche les especes qui ont au moins une maturité sur l'ensemble des
données.
|
Collection<String> |
getSpeciesWithSizeAllYears(Selection selection)
Touve toutes les especes qui ont des tailles pour toutes les années.
|
List<Coordinate> |
getStrataHaulCoordinate(Selection selection,
Collection<String> strataCollection)
Get all strata's haul coordinates of given strata.
|
Selection |
initProjectSelection(Project project)
Creer une instance de selection "non sauvegardee" avec les données
de control (validée) du projet.
|
Selection |
initProjectSelectionFromFile(Project project,
File selectionFile)
Initialise une nouvelle selection à partir des données de controle
et de la definition de la selection du fichier fournit.
|
boolean |
isSpeciesNameExist(Project project,
String newSpeciesName)
Test que le nom de la nouvelle espece existe dans le Reftax actuellement
utilisé par le projet.
|
Project |
loadControlData(Project project)
Load control data in an initialized project.
|
Project |
loadControlDataToSelection(Project project,
Selection selection)
Recharge les données de control et les copies dans la selection.
|
protected List<RSufiResult> |
loadRSufiResults(File selectionDirectory)
Load rsufi result in specified directory.
|
Project |
loadSelectionData(File projectsDirectory,
Project project,
Selection selection)
Load selection data in an initialized project form specific directory.
|
Project |
loadSelectionData(Project project,
Selection selection)
Load selection data in an initialized project.
|
Project |
mergeSpecies(Project project,
Selection selection,
String newSpeciesName,
String comment,
String... speciesNames)
Fusion d'especes.
|
Project |
openProject(String projectName)
Open project without loading data.
|
Project |
openProject(String projectName,
File parentDirectory)
Open project without loading data.
|
Selection |
openSelection(String projectName,
String selectionName)
Open selection (without opening associated project) without associated
data (just properties info).
|
void |
replaceData(Project project,
Control control,
CoserConstants.Category category,
String[] data)
Replace all bean data.
|
boolean |
replaceFieldValue(Project project,
CoserConstants.Category category,
String headerName,
String searchString,
String replaceString,
String[] data,
boolean isRegex,
String commandUUID)
Replace une valeur d'un champs si nécéssaire.
|
void |
saveProject(Project project,
List<File> maps)
Sauve seulement les informations concernant le projet et les cartes
si elle ont été modifiée par rapport à la liste des cartes actuellement
dans le projet.
|
void |
saveProjectControl(Project project)
Enregistre les fichiers de données apres validation.
|
void |
saveProjectSelection(Project project,
Selection selection)
Save project selection.
|
void |
saveRSufiResult(File rsufiResultDirectory,
RSufiResult rsufiResult)
Save rsufi result (only properties file).
|
void |
saveRsufiResults(Project project,
Selection selection,
RSufiResult rsufiResult,
List<File> othersFiles)
Create new rsufi result list in directory structure.
|
protected Project |
updateProjectMaps(Project project,
File projectDirectory,
List<File> newMaps)
Update project maps with new maps.
|
void |
validControl(Project project,
List<ControlError> validationErrors)
Marque le controle comme valider et sauve le projet.
|
void |
validSelection(Project project,
Selection selection)
Marque la selection comme validée et sauve le projet.
|
protected CoserBusinessConfig config
protected CommonService commonService
protected CommandService commandService
protected PublicationService publicationService
public ProjectService(CoserBusinessConfig config)
public List<String> getProjectNames()
public Project createProject(Project project, Map<CoserConstants.Category,File> categoriesAndFiles, List<File> maps, ProgressMonitor progress) throws CoserBusinessException
project
- project to createcategoriesAndFiles
- additional files to loadmaps
- maps fileprogress
- progress monitor (can be null)CoserBusinessException
- if project can't be createdpublic void saveProject(Project project, List<File> maps) throws CoserBusinessException
project
- projectmaps
- mapsCoserBusinessException
protected Project updateProjectMaps(Project project, File projectDirectory, List<File> newMaps) throws CoserBusinessException
project
- project to update mapsprojectDirectory
- project directorynewMaps
- new maps to setCoserBusinessException
public Project openProject(String projectName) throws CoserBusinessException
projectName
- project name to openCoserBusinessException
public Project openProject(String projectName, File parentDirectory) throws CoserBusinessException
projectName
- project name to openparentDirectory
- optional custom parent directory (for results)CoserBusinessException
protected List<RSufiResult> loadRSufiResults(File selectionDirectory) throws CoserBusinessException
selectionDirectory
- selection directoryCoserBusinessException
public RSufiResult getRSufiResult(File resultDirectory) throws CoserBusinessException
RSufiResult
initialise avec les données
du resultat du répertoire demandé.resultDirectory
- result directory (base)CoserBusinessException
public Project loadControlData(Project project) throws CoserBusinessException
project
- projectCoserBusinessException
public Project loadSelectionData(Project project, Selection selection) throws CoserBusinessException
project
- projectselection
- selection to fillCoserBusinessException
public Project loadSelectionData(File projectsDirectory, Project project, Selection selection) throws CoserBusinessException
projectsDirectory
- directory containing projectsproject
- projectselection
- selection to fillCoserBusinessException
public void saveProjectControl(Project project) throws CoserBusinessException
project
- project to saveCoserBusinessException
public void validControl(Project project, List<ControlError> validationErrors) throws CoserBusinessException
project
- project to savevalidationErrors
- controls errors used to fill pdfCoserBusinessException
public void validSelection(Project project, Selection selection) throws CoserBusinessException
project
- project to saveCoserBusinessException
public Selection initProjectSelection(Project project) throws CoserBusinessException
project
- project to create selectionCoserBusinessException
public Selection initProjectSelectionFromFile(Project project, File selectionFile) throws CoserBusinessException
project
- project (containing data in control)selectionFile
- selection fileCoserBusinessException
protected Selection copyControlDataToSelection(Project project, Selection selection)
public void createProjectSelection(Project project, Selection selection) throws CoserBusinessException
project
- project to create selectionselection
- selection to createCoserBusinessException
public void saveProjectSelection(Project project, Selection selection) throws CoserBusinessException
project
- project to save selectionselection
- selection to saveCoserBusinessException
public void saveRsufiResults(Project project, Selection selection, RSufiResult rsufiResult, List<File> othersFiles) throws CoserBusinessException
project
- projectselection
- selectionrsufiResult
- new result to saveothersFiles
- others files and directoryCoserBusinessException
public void editRsufiResults(Project project, Selection selection, RSufiResult rsufiResult, List<File> othersFile) throws CoserBusinessException
project
- projectselection
- selectionrsufiResult
- new result to saveCoserBusinessException
public void saveRSufiResult(File rsufiResultDirectory, RSufiResult rsufiResult) throws CoserBusinessException
rsufiResultDirectory
- rsufiresult directoryrsufiResult
- rsufi resultCoserBusinessException
public void deleteRSufiResult(Project project, Selection selection, RSufiResult rsufiResult) throws CoserBusinessException
project
- projectselection
- selectionrsufiResult
- rsufi result to deleteCoserBusinessException
protected void addHistoryCommandsToProperties(Properties props, List<Command> historyCommand, String propertyPrefix) throws CoserBusinessException
props
- proparties to add command tohistoryCommand
- command list to savepropertyPrefix
- property prefixCoserBusinessException
protected List<Command> getHistoryCommandsFromProperties(Properties props, String propertyPrefix) throws CoserBusinessException
props
- properties to parsepropertyPrefix
- property prefixCoserBusinessException
protected String convertCommandToLine(Command command)
command
- command to convertCoserBusinessException
protected Command convertLineToCommand(String line) throws CoserBusinessException
line
- line to convertCoserBusinessException
protected void addProjectContent(Project project, AbstractDataContainer container, CoserConstants.Category category, DataStorage content, boolean deletedContent)
project
- projectcategory
- categorycontent
- content to setdeletedContent
- if content means deleted objects for category
protected DataStorage getProjectContent(Project project, AbstractDataContainer container, CoserConstants.Category category, boolean deletedContent)
project
- projectcontainer
- data containercategory
- categorydeletedContent
- if content means deleted objects for category
public void deleteData(Project project, Control control, CoserConstants.Category category, String index, String commandUUID) throws CoserBusinessException
project
- projectcontrol
- controlcategory
- categoryindex
- index to deletecommandUUID
- command UUIDCoserBusinessException
public void deleteData(Project project, Control control, CoserConstants.Category category, String index) throws CoserBusinessException
project
- projectcontrol
- controlcategory
- categoryindex
- index to deleteCoserBusinessException
public boolean replaceFieldValue(Project project, CoserConstants.Category category, String headerName, String searchString, String replaceString, String[] data, boolean isRegex, String commandUUID) throws CoserBusinessException
currentValue
is not equals to current data value for fieldName,
no replacement is performed.project
- projectcategory
- categoryheaderName
- headerNamesearchString
- current valuereplaceString
- new valuedata
- current dataisRegex
- is regexcommandUUID
- commandUUIDCoserBusinessException
public void replaceData(Project project, Control control, CoserConstants.Category category, String[] data) throws CoserBusinessException
project
- projectcontrol
- controlcategory
- categorydata
- new data to setCoserBusinessException
public Project loadControlDataToSelection(Project project, Selection selection) throws CoserBusinessException
project
- projectselection
- selection to copy data toCoserBusinessException
public List<String> getProjectYears(Selection selection)
selection
- selection to search intopublic List<String> filterDataYearsAndGetStrata(Project project, Selection selection, List<String> selectedYears) throws CoserBusinessException
Selection.setSelectedYears(List)
, and use
it to known if control data need to be reloaded (don't set it yourself).
Used in selection ui.project
- projectselection
- selectionselectedYears
- selected yearsCoserBusinessException
public void filterDataStrata(Project project, Selection selection, List<String> selectedStrata)
project
- projectselection
- selectionselectedStrata
- selected stratapublic Map<String,String> getProjectSpeciesTypes(Project project)
project
- project to search intopublic void filterDataSpecies(Project project, Selection selection, List<String> selectedSpecies)
project
- projectselection
- selectionselectedSpecies
- selected speciespublic Collection<String> getSpeciesWithSizeAllYears(Selection selection)
selection
- selection to search intopublic Collection<String> getSpeciesWithMaturity(Selection selection)
selection
- selection to search intopublic List<String> getProjectSpecies(AbstractDataContainer container, Project project, Collection<String> filterSpecyType)
beginYear
-endYear
].
Used in selection ui.
Cette liste est issue du fichier captures (petit fichier, mais suffisant).
Les especes sont determinées :
- en lisant les traits pour determiner les traits à partir des zones
- en lisant les captures pour determiner les especes à partir des traits
- en filtrant la liste des especescontainer
- data containerproject
- project (can be null
, no filtering)filterSpecyType
- filterSpecyType (can be null
, no filtering)public boolean isSpeciesNameExist(Project project, String newSpeciesName)
project
- project (avec reftax)newSpeciesName
- species code to testtrue
if specy name existpublic Project mergeSpecies(Project project, Selection selection, String newSpeciesName, String comment, String... speciesNames) throws CoserBusinessException
project
- projectselection
- selectionnewSpeciesName
- new specy name (after merge)comment
- commentspeciesNames
- species name to mergeCoserBusinessException
public org.nuiton.math.matrix.MatrixND getSamplingEffort(Project project, Selection selection)
null
if there is not enought data to build matrix.project
- projectselection
- selectionpublic org.nuiton.math.matrix.MatrixND getOccurrence(Project project, Selection selection)
project
- selection
- public org.nuiton.math.matrix.MatrixND getDensity(Project project, Selection selection)
project
- projectselection
- selectionpublic org.nuiton.math.matrix.MatrixND getLengthStructure(Project project, AbstractDataContainer dataContainer)
project
- projectdataContainer
- data containerpublic void fillLengthStructureMatrix(Project project, AbstractDataContainer dataContainer, org.nuiton.math.matrix.MatrixND matrix)
project
- projectdataContainer
- data containermatrix
- non proxy matrix to fill (inited with 0.0)protected double getHalfStepValue(double value)
value
- value to get hasl steppublic File extractRSUfiData(Project project, Selection selection, File directory, boolean onlyDataTable) throws CoserBusinessException
project
- projectselection
- selectiondirectory
- directory to extract file toonlyDataTable
- extract only data table without additionnal informationCoserBusinessException
protected void fillListSpeciesFile(Selection selection, File ouputFile) throws CoserBusinessException
selection
- selectionouputFile
- output fileCoserBusinessException
- ectionpublic String getProjectSurveyName(File resultDirectory, RSufiResult rSufiResult) throws CoserBusinessException
resultDirectory
- result directoryrSufiResult
- rsufi resultCoserBusinessException
public List<Coordinate> getStrataHaulCoordinate(Selection selection, Collection<String> strataCollection) throws CoserBusinessException
selection
- project's selectionstrataCollection
- starta collection to get haulCoserBusinessException
public SortedMap<String,List<String>> getSelectionByProject()
public Selection openSelection(String projectName, String selectionName) throws CoserBusinessException
projectName
- project containing selectionselectionName
- selection name to open in projectCoserBusinessException
public void fillListsSelection(Selection selection, List<String> selectedSpeciesOccDens, List<String> selectedSpeciesSizeAllYear, List<String> selectedSpeciesMaturity)
selection
- selectedSpeciesOccDens
- selectedSpeciesSizeAllYear
- selectedSpeciesMaturity
- public LinkedHashMap<String,String> getReftaxSpeciesDisplayFieldMap(Project project, boolean outputField)
project
- le projet pour avoir accès au reftaxoutputField
- meme algorithm, mais renvoi une map de correspondance
pour le champ de sortiepublic void editSelectionOptions(Project project, Selection selection, List<File> othersFile) throws CoserBusinessException
project
- projectselection
- selectionrsufiResult
- new result to saveCoserBusinessException
Copyright © 2010–2015 Ifremer. All rights reserved.