5623 |
06 May 11 |
nicklas |
1 |
/** |
5623 |
06 May 11 |
nicklas |
$Id$ |
5623 |
06 May 11 |
nicklas |
3 |
|
5623 |
06 May 11 |
nicklas |
Copyright (C) 2011 Nicklas Nordborg |
5623 |
06 May 11 |
nicklas |
5 |
|
5623 |
06 May 11 |
nicklas |
This file is part of BASE - BioArray Software Environment. |
5623 |
06 May 11 |
nicklas |
Available at http://base.thep.lu.se/ |
5623 |
06 May 11 |
nicklas |
8 |
|
5623 |
06 May 11 |
nicklas |
BASE is free software; you can redistribute it and/or |
5623 |
06 May 11 |
nicklas |
modify it under the terms of the GNU General Public License |
5623 |
06 May 11 |
nicklas |
as published by the Free Software Foundation; either version 3 |
5623 |
06 May 11 |
nicklas |
of the License, or (at your option) any later version. |
5623 |
06 May 11 |
nicklas |
13 |
|
5623 |
06 May 11 |
nicklas |
BASE is distributed in the hope that it will be useful, |
5623 |
06 May 11 |
nicklas |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
5623 |
06 May 11 |
nicklas |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
5623 |
06 May 11 |
nicklas |
GNU General Public License for more details. |
5623 |
06 May 11 |
nicklas |
18 |
|
5623 |
06 May 11 |
nicklas |
You should have received a copy of the GNU General Public License |
5623 |
06 May 11 |
nicklas |
along with BASE. If not, see <http://www.gnu.org/licenses/>. |
5623 |
06 May 11 |
nicklas |
21 |
*/ |
5623 |
06 May 11 |
nicklas |
22 |
package net.sf.basedb.util.fileset; |
5623 |
06 May 11 |
nicklas |
23 |
|
5623 |
06 May 11 |
nicklas |
24 |
import java.util.ArrayList; |
5623 |
06 May 11 |
nicklas |
25 |
import java.util.List; |
5623 |
06 May 11 |
nicklas |
26 |
|
5623 |
06 May 11 |
nicklas |
27 |
import net.sf.basedb.core.signal.ThreadSignalHandler; |
8144 |
21 Apr 23 |
nicklas |
28 |
import net.sf.basedb.util.extensions.AbstractRenderer; |
8144 |
21 Apr 23 |
nicklas |
29 |
import net.sf.basedb.util.extensions.Extension; |
5623 |
06 May 11 |
nicklas |
30 |
|
5623 |
06 May 11 |
nicklas |
31 |
/** |
5623 |
06 May 11 |
nicklas |
Renderer implementation for resetting metadata for the members of a file set. |
5623 |
06 May 11 |
nicklas |
33 |
|
5623 |
06 May 11 |
nicklas |
@author Nicklas |
5623 |
06 May 11 |
nicklas |
@since 3.0 |
5623 |
06 May 11 |
nicklas |
@base.modified $Date$ |
5623 |
06 May 11 |
nicklas |
37 |
*/ |
5623 |
06 May 11 |
nicklas |
38 |
public class ResetMetadataRenderer |
8144 |
21 Apr 23 |
nicklas |
39 |
extends AbstractRenderer<ValidationAction> |
5623 |
06 May 11 |
nicklas |
40 |
{ |
5623 |
06 May 11 |
nicklas |
41 |
|
5623 |
06 May 11 |
nicklas |
42 |
private final List<ValidatingFileSetMember> members; |
5623 |
06 May 11 |
nicklas |
43 |
|
5623 |
06 May 11 |
nicklas |
44 |
/** |
5623 |
06 May 11 |
nicklas |
Create a new renderer instance. |
5623 |
06 May 11 |
nicklas |
46 |
|
5623 |
06 May 11 |
nicklas |
@param members A list with the members of the file set that should have |
5623 |
06 May 11 |
nicklas |
their metadata reset |
5623 |
06 May 11 |
nicklas |
49 |
*/ |
5623 |
06 May 11 |
nicklas |
50 |
public ResetMetadataRenderer(List<ValidatingFileSetMember> members) |
5623 |
06 May 11 |
nicklas |
51 |
{ |
5623 |
06 May 11 |
nicklas |
52 |
this.members = members; |
5623 |
06 May 11 |
nicklas |
53 |
} |
5623 |
06 May 11 |
nicklas |
54 |
|
5623 |
06 May 11 |
nicklas |
55 |
/* |
5623 |
06 May 11 |
nicklas |
From the Renderer interface |
5623 |
06 May 11 |
nicklas |
57 |
--------------------------- |
5623 |
06 May 11 |
nicklas |
58 |
*/ |
5623 |
06 May 11 |
nicklas |
59 |
@Override |
8144 |
21 Apr 23 |
nicklas |
60 |
public void render(ValidationAction action, Extension<? extends ValidationAction> ext) |
5623 |
06 May 11 |
nicklas |
61 |
{ |
5623 |
06 May 11 |
nicklas |
62 |
ThreadSignalHandler.checkInterrupted(); |
5623 |
06 May 11 |
nicklas |
63 |
|
5623 |
06 May 11 |
nicklas |
// Check if the action accepts any file(s) |
5623 |
06 May 11 |
nicklas |
65 |
List<ValidatingFileSetMember> accepted = new ArrayList<ValidatingFileSetMember>(); |
5623 |
06 May 11 |
nicklas |
66 |
for (ValidatingFileSetMember member : members) |
5623 |
06 May 11 |
nicklas |
67 |
{ |
5623 |
06 May 11 |
nicklas |
68 |
Accept accept = member.isAcceptedByValidator(action); |
5623 |
06 May 11 |
nicklas |
69 |
if (accept == Accept.VALIDATE_IMMEDIATELY) |
5623 |
06 May 11 |
nicklas |
70 |
{ |
5623 |
06 May 11 |
nicklas |
// Reset metadata immediately |
5623 |
06 May 11 |
nicklas |
72 |
action.resetMetadata(); |
5623 |
06 May 11 |
nicklas |
73 |
} |
5623 |
06 May 11 |
nicklas |
74 |
else if (accept == Accept.VALIDATE_LATER) |
5623 |
06 May 11 |
nicklas |
75 |
{ |
5623 |
06 May 11 |
nicklas |
// File will be used in batch later |
5623 |
06 May 11 |
nicklas |
77 |
accepted.add(member); |
5623 |
06 May 11 |
nicklas |
78 |
} |
5623 |
06 May 11 |
nicklas |
79 |
} |
5623 |
06 May 11 |
nicklas |
80 |
|
5623 |
06 May 11 |
nicklas |
// Are there any files waiting for validation? |
5623 |
06 May 11 |
nicklas |
82 |
if (accepted.size() == 0) return; |
5623 |
06 May 11 |
nicklas |
83 |
|
5623 |
06 May 11 |
nicklas |
// Reset metadata for the remaining files |
5623 |
06 May 11 |
nicklas |
85 |
action.resetMetadata(); |
5623 |
06 May 11 |
nicklas |
86 |
} |
5623 |
06 May 11 |
nicklas |
87 |
// --------------------------------- |
5623 |
06 May 11 |
nicklas |
88 |
} |