Repository for the HealthTool which enables Apple users to analyse their health data from the Apple health app and prepares the data for contributing it for future studies on wearable data.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

138 lines
3.5 KiB

package application.helpers.wrappers;
import java.util.ArrayList;
import java.util.List;
import org.xml.sax.Attributes;
import application.customviews.EntryView;
import application.enums.EntryType;
import application.res.Text;
import javafx.scene.Node;
import javafx.scene.layout.VBox;
/**
* This class wraps the selection of the user regarding which data should be
* included in the created files
*
* @author Bianca
*
*/
public class WriteSelection
{
/** All selected EntryTypes (even if only one sub element is selected)**/
private List<EntryType> select = new ArrayList<>();
/** All sub records selected **/
private List<String> recordSelected = new ArrayList<>();
/** All sub workouts selected**/
private List<String> workoutSelected = new ArrayList<>();
/** All date of birth parts selected**/
private List<String> dateOfBirthSelected = new ArrayList<>();
/**
* Constructor which extracts the selection from the {@link EntryView}s
* @param datalist The list containing all the {@link EntryView}s
*/
public WriteSelection(VBox datalist)
{
for(Node n: datalist.getChildren())
{
if(n instanceof EntryView)
{
EntryView i = (EntryView)n;
if (i.getSelected())
{
if(i.getEntryType().equals(EntryType.WORKOUT))
{
workoutSelected=i.getSelectedSubElementNames();
}
if(i.getEntryType().equals(EntryType.DATE_OF_BIRTH))
{
dateOfBirthSelected=i.getSelectedSubElementNames();
}
select.add(i.getEntryType());
if(i.getEntryType().equals(EntryType.RECORD))
{
recordSelected=i.getSelectedSubElementNames();
}
}
}
}
}
/**
* Determines whether the given date of birth part is selected
* @param birthPart part to check (Year, month or day)
* @return {@code True} if it is selected, {@code False} otherwise
*/
public boolean birthPartSelected(String birthPart)
{
return dateOfBirthSelected.contains(birthPart);
}
/**
* Determines whether the workout of these attributes is selected
* @param attributes The attributes of the workout which also contain the type
* @return {@code True} if it is selected, {@code False} otherwise
*/
public boolean workoutSelected(Attributes attributes)
{
return workoutSelected.contains(attributes.getValue(Text.TAG_ATTR_WORKOUT_TYPE));
}
/**
* Returns all selected sub workouts
* @return The described value
*/
public List<String> getWorkouts()
{
return workoutSelected;
}
/**
* Determines whether the record of these attributes is selected
* @param attributes The attributes of the record which also contain the type
* @return {@code True} if it is selected, {@code False} otherwise
*/
public boolean recordSelected(Attributes attributes)
{
return recordSelected.contains(attributes.getValue(Text.TAG_ATTR_RECORD_TYPE));
}
/**
* Returns all selected sub records
* @return The described value
*/
public List<String> getRecords()
{
return recordSelected;
}
/**
* Determines whether the {@link EntryType} of these attributes is selected
* @param entry The entry to compare
* @return {@code True} if it is selected, {@code False} otherwise
*/
public boolean entrySelected(EntryType entry)
{
return select.contains(entry);
}
/**
* Returns all selected date of birth parts
* @return The described value
*/
public List<String> getBirthParts()
{
return dateOfBirthSelected;
}
/**
* Returns all selected {@link EntryType}s
* @return The described value
*/
public List<EntryType> getEntryTypes()
{
return select;
}
}